Typed predicates + SQLite spellfix1 handle to retire raw SQL fragments#2
Merged
Conversation
Add typed query-builder surface for cases that previously forced raw Where/Set/Field fragments: - OnConflict(...).DoNothing(): ignore a conflicting row on upsert — ON CONFLICT DO NOTHING on SQLite/Postgres, a no-op ON DUPLICATE KEY UPDATE on MySQL, and a MERGE with no matched arm on SQL Server. - Column.HasPrefix/HasSuffix/Contains: LIKE with the needle's % and _ escaped so user input matches literally (LIKE ? ESCAPE '~'). - Column.EqCol/Of and ExistsField: column-to-column equality, and a correlated EXISTS projected as a portable CASE WHEN EXISTS(...) boolean column. - UpdateBuilder.Inc/Dec: atomic col = col +/- n. - PluckExpr/PluckExprFirst: project a raw scalar expression into []V / V. - query.Match + dialect.FeatMatch: the SQLite MATCH operator as a feature-gated predicate, rejected at build time on other dialects. Covered by render tests across all four dialects, real-SQLite behavior tests, and ormsuite conformance (DoNothing, HasPrefix escaping, Inc, PluckExpr, ExistsField). Query guide, recipes, pitfalls, and orm/orm-models skills updated to the typed forms.
Add a typed handle for gosqlite's spellfix1 fuzzy-match vocabulary — the third SQLite search extension alongside Vector and FullText. NewSpellfix/OpenSpellfix create or attach a vocabulary, Add populates it (one transaction, deduped), Correct returns the nearest words by edit distance, and Size/Drop/Name round it out. It delegates to gosqlite's spellfix1.Vocab over the session's *sql.DB, so create, populate, and query are all typed — no hand-written virtual-table SQL. Importing the package registers the spellfix1 module. Also documents the SQLite MATCH predicate and the spellfix1 handle in the sqlite-search guide and skill, and exercises MATCH against a spellfix1 vtab.
ditalini
approved these changes
Jun 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds typed query-builder surface for the cases that previously forced raw
Where/Set/Fieldfragments in otherwise-typed code, plus a typed handle for SQLite's spellfix1 fuzzy-match vocabulary. Two commits: the portable predicates, then the spellfix1 handle.Typed predicates & helpers (portable across all four dialects):
OnConflict(...).DoNothing()— ignore a conflicting row on upsert:ON CONFLICT DO NOTHING(SQLite/Postgres), a no-opON DUPLICATE KEY UPDATE(MySQL), aMERGEwith no matched arm (SQL Server).Column.HasPrefix/HasSuffix/Contains— LIKE with the needle's%/_escaped so user input matches literally (LIKE ? ESCAPE '~').Column.EqCol/Of+ExistsField— column-to-column equality, and a correlated EXISTS projected as a portableCASE WHEN EXISTS(...) THEN 1 ELSE 0 ENDboolean column.UpdateBuilder.Inc/Dec— atomiccol = col ± n.PluckExpr/PluckExprFirst— project a raw scalar expression (MAX(x),COALESCE(...),rowid) into[]V/V.SQLite:
query.Match+dialect.FeatMatch— theMATCHoperator as a feature-gated predicate, rejected at build time on non-SQLite dialects.dialect/sqlite/search.Spellfix— a typed fuzzy-correction vocabulary (NewSpellfix/OpenSpellfix/Add/Correct/Size/Drop), the third extension handle alongsideVectorandFullText. It delegates to gosqlite'sspellfix1.Vocab, so create/populate/query are all typed — no hand-written virtual-table SQL.