Conversation
lingcoder
requested review from
gqcn and
hailaz
and removed request for
hailaz
September 23, 2026 22:10
lingcoder
force-pushed
the
test/sqlite-driver-test-coverage
branch
from
September 23, 2026 22:27
71228ad to
9b621a0
Compare
Adds the 28 feature suites the MySQL baseline has and SQLite lacked, taking the driver from 158 to 521 test functions with the same names as their MySQL counterparts. Four suites are not added: master_slave and lock have no SQLite counterpart, partition is a no-op on every driver (gogf#4826), and the MySQL issue suite reproduces MySQL-only reports. Test_Model_Schema1/2 are omitted for the same reason as master_slave. Expectations that differ from MySQL are the ones SQLite defines differently: a single isolation level, `database is locked` instead of deadlocks, storage classes instead of declared types, JSON1 functions instead of a JSON column type. Test_Model_Cache_Force stays the stub every other driver carries: CacheOption.Force never caches an empty result (gogf#4891), and the note here says so.
…into forms SQLite accepts Union and UnionAll never worked on SQLite: the core builds them as `(SELECT ...) UNION (SELECT ...)`, and SQLite forbids parentheses around the operands of a compound SELECT. WhereExists and WhereNotExists failed the same way: `EXISTS (?)` with a sub-query argument expands to `EXISTS ((SELECT ...))`. The driver now rewrites the statement in DoFilter, matching parentheses rather than patterns: each compound operand becomes `SELECT * FROM (...)`, which also keeps a per-operand ORDER BY or LIMIT legal, and the doubled parentheses of EXISTS are reduced to one pair. The sqlitecgo driver has the same defect and gets the same rewrite in its own change.
lingcoder
force-pushed
the
test/sqlite-driver-test-coverage
branch
from
September 24, 2026 02:27
e341dd8 to
84fcc57
Compare
lingcoder
force-pushed
the
test/sqlite-driver-test-coverage
branch
from
September 24, 2026 03:40
84fcc57 to
45e8dab
Compare
This branch has not been deployed
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.
ref #4689
Summary
Brings the SQLite driver up to the MySQL baseline. Test functions go from 161 to 561:
sqlite_z_unit_feature_sqlite_test.go, 35 functions for behaviour that is SQLite's own: storage classes andtypeof,WITHOUT ROWID, JSON1, window functions, CTEs,RETURNING,ON CONFLICT,INSERT OR IGNORE/REPLACE,LIMIT -1,last_insert_rowid(),EXPLAIN QUERY PLAN, date/time functions,RANDOM()ordering, theextraDSN pragmas.Nothing under
database/is touched.Four suites are not ported, on purpose:
master_slavelockFOR UPDATE/FOR SHARE;LockUpdate()yields invalid SQLpartitionModel.Partition()is a no-op on every driver (#4826); a suite of skips asserts nothingissueTest_Model_Schema1/2are omitted for the same reason asmaster_slave.Where SQLite defines behaviour differently, the expectations follow SQLite, verified by running rather than reasoned about: one isolation level,
database is lockedin place of deadlocks, storage classes in place of declared types, JSON1 functions in place of a JSON column type,busy_timeout+ WAL for the multi-connection scenarios.Bugs found
Porting surfaced five. Two are fixed here because the tests cannot pass without them and the fix is confined to the SQLite drivers; the others are tracked separately.
1.
Union/UnionAllnever worked on SQLite. The core builds(SELECT ...) UNION (SELECT ...); SQLite forbids parentheses around compound operands. Not one existing test touchedUnion, so this was never noticed. Fixed inDoFilterof both sqlite and sqlitecgo: each operand becomesSELECT * FROM (...), which keeps a per-operandORDER BY/LIMITlegal too. Parentheses are matched, not pattern-guessed; string literals are skipped.2.
WhereExists/WhereNotExistsfail on SQLite.Wheref("EXISTS (?)", subQuery)expands toEXISTS ((SELECT ...)), which SQLite rejects. Fixed in the sameDoFilter: the doubled pair is reduced to one.3.
CacheOption.Forcenever caches an empty result — #4891.All()returns a nilResultfor no rows, which skips theForcebranch insaveSelectResultToCache. Core logic, reproduced identically on MySQL. Every driver carries an emptyTest_Model_Cache_Forcefor this reason, with a note that misstates why; this one is the same stub but says why. The scenario gets asserted, in every driver, with the fix for #4891.4. A column holding mixed storage classes is typed from its first row — #4895. Once the first row is an INTEGER, later REAL / TEXT / BLOB rows of the same column are coerced to int64 and read back as
1/0. Core logic (theScanTypefast path incolumnValueToLocalValue), and specific to the modernc driver, which reports the first row's Go type as the column's scan type; sqlitecgo is not affected.Test_SQLite_Type_StorageClass_MixedRowsis kept as a stub pointing to #4895 and gets its assertions with that fix; the per-row single-value reads are asserted inTest_SQLite_Type_StorageClass_Typeof.5. A
POINTcolumn reads back as0— #4842, fixed by #4882 which has since merged;Test_DataType_Geometry_Pointpasses on the rebased branch.Verification
Full suite on Windows 11 with an isolated temp dir,
-count=1, ond924ae001:The
DoFilterrewrite has its own unit tests (sqlite_z_unit_do_filter_test.go) covering the shapes the core emits, nested sub-queries, and parentheses inside string literals. The existing sqlitecgo suite passes with the shared rewrite.