Repository navigation
v2.0.0-rc.1
Pre-release
Pre-release
·
105 commits
to main
since this release
Changed
- The checker is the product; the runtime is a library per database. The root module
github.com/kr9ly/sqlshape/v2now holds only the declarations (Query,One,Stmt,Render,
the row-binding rules) and has no dependencies. Running a statement on pgx is the module
github.com/kr9ly/sqlshape/postgres/v2:postgres.Run(ctx, db, stmt, p),Collect,First,
Exec,Get/Find/ExecOneforOne, andMatView,Copy,Batch,LoadUserTypes,
ConstraintError,Violates,ErrNoRowsmoved there (the methodsstmt.Run(ctx, db, p)are
gone: a module cannot add methods to another's type).LabelledandUnknownLabelErrorstay in
the root.pgtestis its own module. The PostgreSQL analyzer and migration tools are the module
github.com/kr9ly/sqlshape/check/postgres/v2, the MySQL analyzercheck/mysql(wasmysql);
both are tool-facing, imported by the binary andpgtest. An application's go.mod carries the
root, its runtime and its own driver, nothing of the checker's. - The markers the checker recognizes are configurable:
-query=pkg.Func,pkg.Other:oneregisters
a program's own generic marker functions, read likeQuery/One. A program may run its
statements through a runtime of its own; what only sqlshape's runtime promises (the rendered SQL
is the checked SQL, violations come back under the expect line's names,Onerejects a second
row) is stated in docs/runtime.md.
Added
- MySQL, a first slice. A
schema.sqlthat declares-- sqlshape: mysql 8.4is loaded by the
MySQL schema loader and everyQueryis judged by the MySQL analyzer: the statement's own errors
(unknown table or column, ambiguity, syntax, with MySQL's message and error number), result
columns againstRby name, type and nullability, parameters againstPwhere their context
types them (compared with or assigned to a column,LIMIT, the argument positions a function
declares). Single-block SELECT, INSERT, UPDATE and DELETE over base tables. Expressions are typed
by the server's own rules, read out of its source: arithmetic promotion (Item_num_op),CASE/
IF/COALESCE/GREATESTthroughfield_type_merge, casts, aggregates, and every function of
the native registry through its Item class family andresolve_typefacts, so aSUMis a
nullable decimal, a comparison abigint(1)a Goboolcan carry,LENGTH(?)types its
placeholder as a string. The rules are checked against a real mysqld (a local test, not a CI
dependency): every registry function over representative argument types, 5,267 statements,
agrees with the server on type and nullability but for 10. Subqueries (scalar,IN,EXISTS,
ANY/ALL, correlated), derived tables (LATERALtoo), views, common table expressions
(recursive too),UNION/EXCEPT/INTERSECTandINSERT ... SELECTare analyzed with the
server's rules for what they produce: a scalar subquery is NULL unless its query is guaranteed a
row, a recursive CTE's columns are always nullable, a derived table the server materializes
retypes a small integer expression to an int, a merged view is updatable. What has no rule yet
(user variables, the temporal hybrids such asADDTIME) is accepted with a note;One,
MatView,Copyand the obligations are not supported yet. Parameters stay{{.X}}in the
template; the analyzer speaks?to MySQL.
Changed
- The binary is its own Go module,
github.com/kr9ly/sqlshape/cmd/sqlshape/v2, under the GNU
General Public License v2; install it withgo install github.com/kr9ly/sqlshape/cmd/sqlshape/v2@latest.
Everything a checked program imports stays Apache 2.0. Every module's path carries the/v2
major-version suffix Go requires of a 2.x module, so an import of 1.x is
github.com/kr9ly/sqlshapeand of 2.xgithub.com/kr9ly/sqlshape/v2. The modules of the
repository release together under one version, taggedvX.Y.Zand<module>/vX.Y.Zon the
same commit.