Add repository interface experiment with SQLite regex filtering#36
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: fdce182760
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| private void loadExistingData() { | ||
| for (EntityDefinition entity : schema.getEntityDefinitions()) { | ||
| loadEntityRows(entity); | ||
| restoreCountersFor(entity); | ||
| } |
There was a problem hiding this comment.
Restore counters before repository writes
For file-backed SQLite repositories, counters are restored only from loadExistingData(), which is only reached when the deprecated compatibility snapshot is requested. If the app restarts and handles normal repository-backed writes before any getInstanceData() call, countersFor() still starts auto-increment fields at their default value, so the next created row reuses ids that already exist in SQLite; with the current persistence path this can overwrite an existing row, and even without that it would make the first create after restart fail. Initialize or lazily restore the counters before writes/counter access, not only when hydrating the snapshot.
Useful? React with 👍 / 👎.
| String sql = "INSERT OR REPLACE INTO " + table(entity) + | ||
| " (" + names + ") VALUES (" + placeholders + ")"; |
There was a problem hiding this comment.
Do not replace rows on unique conflicts
Using SQLite INSERT OR REPLACE here turns any primary-key or unique-field conflict into a delete-and-insert of the existing row. In a file-backed repo after restart, or whenever the in-memory uniqueness check has not hydrated the conflicting row, creating/updating an instance with a duplicate unique value silently removes the old instance instead of returning the existing validation/constraint error, leaving stale relationship rows and losing user data.
Useful? React with 👍 / 👎.
| public void deleteRepository(final String databaseKey) { | ||
| ThingRepository repository = repositories.remove(databaseKey); | ||
| if (repository != null) { | ||
| repository.close(); | ||
| } |
There was a problem hiding this comment.
Remove file-backed database files when deleting repositories
In sqlite-file mode this only removes the repository from the provider and closes the connection; the <databaseKey>.sqlite file remains on disk. Any flow that deletes a logical database and later recreates the same key, such as expired challenger/session cleanup followed by restoring or reusing that id, reopens the old file and exposes the stale data that deletion was expected to discard.
Useful? React with 👍 / 👎.
Summary
~=filtersREGEXPfunction for regex filters that cannot safely convert toLIKESimpleQueryas an ERInstanceData-backed compatibility pathValidation
All validation passed locally.
Issues