Commit e7b4895
feat(dialect): add MariaDB + Snowflake to playground, fix WASM dialectMap, unify config validation (#432)
* fix(playground): move useState/useCallback above early returns to fix React error #310
useState(copied) and useCallback(handleCopy) were declared after the
if (loading) and if (error) early returns, violating the Rules of Hooks.
When the WASM binary was a 404, the component always hit the error branch
so both renders exited with the same hook count. After committing the WASM
binary (#423), the component now successfully transitions loading→ready,
causing React to see 11 hooks instead of 9 on the second render → #310.
Fix: move both hooks above all conditional returns.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(dialect): add DialectMariaDB constant to keyword dialect system
* fix(dialect): return MYSQL_SPECIFIC for DialectMariaDB and add to validDialects test
* fix(dialect): wire DialectMariaDB into keywords.New() to load MYSQL_SPECIFIC keywords
* test(dialect): add TestDialectMariaDB_InheritsMySQL to guard MySQL keyword inheritance
* feat(dialect): add MARIADB_SPECIFIC keyword list extending MySQL dialect
* feat(dialect): add MariaDB auto-detection hints (SEQUENCE, VERSIONING, CONNECT BY)
* fix(dialect): remove over-broad START WITH hint and complete DetectDialect doc comment
* fix(dialect): restore MariaDB CONNECT BY hint and add accumulation test
* feat(ast): add CreateSequenceStatement, DropSequenceStatement, AlterSequenceStatement nodes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(ast): nil guard in sequence ToSQL, split Restart field, add sequence tests
- Guard s.Name nil dereference in CreateSequenceStatement.ToSQL,
DropSequenceStatement.ToSQL, and AlterSequenceStatement.ToSQL
- Split SequenceOptions.Restart (*LiteralValue) into two fields:
Restart bool (bare RESTART) and RestartWith *LiteralValue (RESTART WITH n)
- Update writeSequenceOptions to emit bare RESTART or RESTART WITH n accordingly
- Add ast_sequence_test.go with full ToSQL table-driven tests and pool round-trip test
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(ast): add ForSystemTimeClause, PeriodDefinition, temporal table fields
- Add SystemTimeClauseType enum with AS OF, BETWEEN, FROM/TO, ALL variants
- Add ForSystemTimeClause struct for MariaDB FOR SYSTEM_TIME temporal queries
- Add PeriodDefinition struct for PERIOD FOR clauses in CREATE TABLE
- Extend TableReference with ForSystemTime field (MariaDB 10.3.4+)
- Extend CreateTableStatement with WithSystemVersioning and PeriodDefinitions fields
- Add ForSystemTimeClause.ToSQL() and tableRefSQL integration in sql.go
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(ast): add SQL() methods to temporal/CONNECT BY types and fix SelectStatement field order
Add SQL() methods to ForSystemTimeClause, ConnectByClause, and PeriodDefinition
(all implement expressionNode()) so they satisfy the Expression interface fully
without silently degrading via the exprSQL() fallback. Move StartWith and
ConnectBy fields in SelectStatement to directly follow Having, matching logical
SQL clause ordering.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(parser): implement CREATE/DROP/ALTER SEQUENCE parsing for MariaDB dialect
Add parseCreateSequenceStatement, parseDropSequenceStatement, and
parseAlterSequenceStatement to mariadb.go with full option parsing
(START WITH, INCREMENT BY, MINVALUE, MAXVALUE, CYCLE, CACHE, RESTART WITH).
Wire dispatch into parseStatement() for DROP/ALTER and into parseCreateStatement()
for CREATE. Gate all paths behind isMariaDB() so MySQL and other dialects
are unaffected. Add six passing parser tests in mariadb_test.go.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(parser): implement temporal table parsing (FOR SYSTEM_TIME, WITH SYSTEM VERSIONING, PERIOD FOR)
Add parseForSystemTimeClause and parseTemporalPointExpression to mariadb.go
supporting AS OF, BETWEEN, FROM/TO, and ALL variants. Hook into
parseFromTableReference in select_subquery.go (after alias, before SQL Server
hints) with a peek-ahead guard so FOR is only consumed when followed by
SYSTEM_TIME. Add WITH SYSTEM VERSIONING parsing to parseCreateTable (after
closing paren, before PARTITION BY) and PERIOD FOR column parsing to the
column loop in ddl.go. Add four passing tests for temporal queries and
system versioning in mariadb_test.go.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(parser): implement CONNECT BY hierarchical query parsing for MariaDB dialect
Add parseConnectByCondition to mariadb.go which handles the PRIOR prefix
operator by wrapping the referenced column in a FunctionCall node and
building a BinaryExpression for the full PRIOR col = parent_col pattern.
Wire START WITH and CONNECT BY [NOCYCLE] parsing into parseSelectStatement
in select.go after the HAVING clause. Guard CONNECT and START from being
consumed as table aliases in parseFromTableReference via a peek-ahead check
in select_subquery.go. Add three passing tests covering basic, NOCYCLE, and
no-START-WITH variants in mariadb_test.go.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(parser): add bare RESTART test and nil guard for CONNECT BY condition
* test(parser): add MariaDB SQL test data files and file-based integration test
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* docs: add MariaDB dialect to SQL_COMPATIBILITY.md and CHANGELOG.md
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(mariadb): address code review issues across AST, keywords, and parser
AST layer:
- Add `Prior` UnaryOperator constant for CONNECT BY PRIOR expressions
- Add `NoCache bool` to SequenceOptions (NOCACHE was previously a silent no-op)
- Add `Pos models.Location` to all 6 new MariaDB AST nodes (CreateSequence,
DropSequence, AlterSequence, ForSystemTimeClause, ConnectByClause, PeriodDefinition)
- Add `NewDropSequenceStatement()` / `ReleaseDropSequenceStatement()` pool funcs
to match Create/Alter sequence pooling consistency
- Emit NOCACHE in writeSequenceOptions when NoCache=true
Keywords:
- Remove duplicate MINVALUE, MAXVALUE, INCREMENT, RESTART, NOCACHE entries
from MARIADB_SPECIFIC (already covered by base/Oracle keyword lists)
Parser:
- Fix PRIOR operator: switch from FunctionCall to UnaryExpression{Operator: Prior}
- Fix PRIOR on RHS: CONNECT BY col = PRIOR col now parsed correctly
- Fix parseJoinedTableRef: add isMariaDBClauseKeyword guard to prevent CONNECT/START
from being consumed as table aliases (same guard already in parseFromTableReference)
- Fix parseJoinedTableRef: add FOR SYSTEM_TIME temporal clause support on JOIN refs
- Fix DROP SEQUENCE: support IF NOT EXISTS in addition to IF EXISTS
- Fix DROP SEQUENCE: use NewDropSequenceStatement() for pool consistency
- Fix parseSequenceOptions: set opts.NoCache=true for NOCACHE keyword
- Add comment in parseTemporalPointExpression explaining quote-stripping behaviour
Tests:
- Add TestMariaDB_ConnectBy_PriorOnRight
- Add TestMariaDB_DropSequence_IfNotExists
- Add TestMariaDB_Sequence_NoCache
- Expand testdata SQL files with NO MINVALUE/MAXVALUE forms, PRIOR-on-right cases,
IF NOT EXISTS on DROP, and multi-table temporal JOIN query
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(mariadb): address second code review pass — Pos, NO CACHE, CONNECT BY, dedup
Parser dispatch (parser.go, ddl.go, select.go):
- Populate Pos on CreateSequenceStatement (at SEQUENCE token in ddl.go)
- Populate Pos on DropSequenceStatement (at DROP token in parser.go)
- Populate Pos on AlterSequenceStatement (at ALTER token in parser.go)
- Populate Pos on ConnectByClause (at CONNECT token in select.go)
- Populate Pos on PeriodDefinition (at PERIOD token in ddl.go)
mariadb.go:
- Fix NO CACHE (two-token) to also set opts.NoCache=true, matching NOCACHE
- Fix parseConnectByCondition to handle complex AND/OR chains:
CONNECT BY PRIOR id = parent_id AND active = 1 now fully parsed
- Extract isMariaDBClauseStart() method (was duplicated closure in two functions)
- Populate Pos on ForSystemTimeClause (at SYSTEM_TIME token)
- Add comment clarifying IF NOT EXISTS is a non-standard permissive extension
select_subquery.go:
- Remove both isMariaDBClauseKeyword closures, replace with p.isMariaDBClauseStart()
ast.go:
- Update DropSequenceStatement doc to show [IF EXISTS | IF NOT EXISTS]
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(mariadb): correct START WITH/CONNECT BY SQL order and implement PeriodDefinition.SQL()
- Move START WITH / CONNECT BY emission to after HAVING, before ORDER BY
- Implement PeriodDefinition.SQL() — was silently returning empty string
- Add round-trip tests for both fixes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(mariadb): code review fixes — pool comments, expressionNode docs, PERIOD FOR SYSTEM_TIME test
- Add '// zero all fields' comment to ReleaseCreateSequenceStatement and ReleaseAlterSequenceStatement
- Add design-choice comments on expressionNode() for ForSystemTimeClause, ConnectByClause, PeriodDefinition
- Add TestMariaDB_CreateTable_PeriodForSystemTime to cover PERIOD FOR SYSTEM_TIME parsing
- Fix parsePeriodDefinition to use parseColumnName so SYSTEM_TIME (reserved keyword) is accepted as period name
- Add GENERATED ALWAYS AS ROW START/END column constraint parsing in parseColumnConstraint (MariaDB system-versioned columns)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(dialect): reduce MariaDB CONNECT BY hint weight to 2 so Oracle wins pure CONNECT BY queries
Oracle's CONNECT BY weight is 3; MariaDB's was also 3, causing a tie broken
by non-deterministic map iteration. Reducing MariaDB to weight 2 ensures
Oracle wins when CONNECT BY is the only hint. MariaDB is still correctly
detected when its unique high-weight hints (NEXTVAL, FOR SYSTEM_TIME, etc.)
are present.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(mariadb): address code review — CycleOption enum, CACHE validation, structured errors
- Replace Cycle bool + NoCycle bool with CycleOption enum to prevent
invalid state where both could be true simultaneously
- Add validation in parseSequenceOptions for contradictory CACHE/NOCACHE
- Replace fmt.Errorf with p.expectedError() for consistent error style
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* bench(mariadb): add MariaDB-specific parsing benchmarks
17 benchmarks across 4 groups:
- BenchmarkMariaDB_Sequence: CREATE/ALTER/DROP SEQUENCE (5 cases)
- BenchmarkMariaDB_ForSystemTime: temporal table queries (5 cases)
- BenchmarkMariaDB_ConnectBy: hierarchical queries with PRIOR (4 cases)
- BenchmarkMariaDB_Mixed: combined features — CTE+temporal, CTE+CONNECT BY,
CREATE TABLE WITH SYSTEM VERSIONING (3 cases)
Baseline (M2): 398–3001 ns/op, 984–6763 B/op
* feat(playground): add Snowflake and MariaDB to dialect dropdown
Closes #428 — Snowflake was missing despite full keyword support.
Closes #426 (partial) — MariaDB playground integration complete.
Playground now exposes all 8 named dialects + Generic (9 total).
* fix(wasm): add mariadb to dialectMap so playground selection takes effect
Without this, selecting MariaDB in the dropdown silently fell back to
generic dialect parsing. The UI entry was a no-op at the parser layer.
* fix(wasm): add clickhouse to dialectMap (pre-existing silent fallback bug)
* fix(config): add snowflake to validDialects and update help text
snowflake was accepted by --dialect flag but rejected when set in
YAML config. Both layers are now consistent.
Part of #428.
* fix(config): add snowflake+mariadb to internal ValidDialects, tests, and doc comments
Add "snowflake" and "mariadb" to the ValidDialects slice and inline
validDialects list in cmd/gosqlx/internal/config, update corresponding
tests, and sync doc comments in pkg/config to reflect all supported
dialects including the two new ones.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(config): update remaining dialect doc strings and LSP runtime description
* docs: update dialect counts 7→8 and add MariaDB to all doc lists
- CLAUDE.md: add Snowflake + MariaDB (was missing both)
- README.md: 7→8 dialects in stats bar, add MariaDB to feature lists
- SQL_COMPATIBILITY.md: 6→8 Supported Dialects (add ClickHouse + MariaDB)
- website/src/lib/constants.ts: add MariaDB to feature description
Resolves #426 (docs integration)
Resolves #428 (count sync)
* docs: update dialect counts in publishing drafts (7→8, add MariaDB)
* chore: remove plan files from PR (internal docs)
---------
Co-authored-by: Ajit Pratap Singh <ajitpratapsingh@Ajits-Mac-mini-2655.local>
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>1 parent 7321908 commit e7b4895
File tree
15 files changed
+30
-20
lines changed- cmd/gosqlx
- cmd
- internal/config
- docs
- pkg/config
- wasm
- website/src
- components/playground
- lib
15 files changed
+30
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
| 143 | + | |
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
92 | | - | |
| 92 | + | |
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
| |||
334 | 334 | | |
335 | 335 | | |
336 | 336 | | |
337 | | - | |
| 337 | + | |
338 | 338 | | |
339 | 339 | | |
340 | 340 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| |||
345 | 345 | | |
346 | 346 | | |
347 | 347 | | |
348 | | - | |
| 348 | + | |
349 | 349 | | |
350 | 350 | | |
351 | 351 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
198 | | - | |
| 198 | + | |
199 | 199 | | |
200 | 200 | | |
201 | 201 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
| |||
225 | 227 | | |
226 | 228 | | |
227 | 229 | | |
228 | | - | |
| 230 | + | |
229 | 231 | | |
230 | 232 | | |
231 | 233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
862 | 862 | | |
863 | 863 | | |
864 | 864 | | |
865 | | - | |
| 865 | + | |
866 | 866 | | |
867 | 867 | | |
868 | 868 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
85 | | - | |
| 85 | + | |
86 | 86 | | |
87 | 87 | | |
88 | 88 | | |
| |||
215 | 215 | | |
216 | 216 | | |
217 | 217 | | |
| 218 | + | |
| 219 | + | |
218 | 220 | | |
219 | 221 | | |
220 | 222 | | |
221 | 223 | | |
222 | 224 | | |
223 | | - | |
| 225 | + | |
224 | 226 | | |
225 | 227 | | |
226 | 228 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
231 | 231 | | |
232 | 232 | | |
233 | 233 | | |
234 | | - | |
| 234 | + | |
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| |||
0 commit comments