Repository navigation
v0.37.0
Changed
- A result column is typed from its expression, not from its alias or from a column name the expression mentions.
SELECT bio AS nameused to be typed as theNOT NULLnamecolumn and failed to decode a NULLbio, andSELECT length(name)used to be typed as thenamecolumn (String). Regenerated code can change type where such a query relied on the old guess. - NULL now propagates through
||, the string, length and date functions (upper(bio),length(bio),date(at)), comparisons,LIKE,BETWEEN,INandNOTin a result column, which becomeOption(...)when an operand is nullable. They wereString,IntorBool, and the generated decoder failed withexpected String, got Nilon the first NULL.IFNULLandNVLkeep their first argument's type and are non-null when an argument is, and aCASTof a column is nullable only when the column is. - With
runtime: "native", a query that reads a DATE, TIME or TIMESTAMP column, or sends such a parameter to PostgreSQL, or reads a PostgreSQL UUID, stopsgenerateandverifywith SQD4013. The generatedStringcould not hold what pog and the MySQL driver return (gleam_time values, tuples, 16 bytes), so every call failed with a decode or argument error. The message names the column and the cast that works, such ascreated_at::text AS created_ator$1::text::timestamptz.
Fixed
- Two result columns with the same name (
SELECT *over a join,upper(name), name) generated a row type with a duplicate field, which did not compile. Later ones get_2,_3, as repeated parameters already did. - A block comment ends at the first
*/in SQLite and MySQL. sqlode nested them as PostgreSQL does, so/* a /* b */ WHERE id = ?dropped theWHEREclause from the generated SQL without an error. - In MySQL,
--starts a comment only when a space or control character follows, so1--1is no longer cut at the dashes. - The PostgreSQL jsonb operator
?(WHERE meta ? 'admin') stopped generation with SQD3004 as if it were a placeholder. - A NUMERIC column with a whole value, such as
10, failed to decode in the pog adapter, which received an Int for aFloatfield. - A parameter compared with
BETWEEN,IS [NOT] DISTINCT FROM, orLIKE ... ESCAPEstoppedgeneratewithcould not infer type for parameter; it takes the column's type now.FILTER (WHERE ...),IS [NOT] UNKNOWNandINTERVAL '...'are parsed instead of being skipped. - A column read through an upper-case
LEFT JOINalias (SELECT B.title FROM authors a LEFT JOIN books B ...) was generated as non-nullable. queries.gleamimportedgleam/optionwhen only a result column was nullable, which Gleam reports as an unused import. The integration builds now use--warnings-as-errors.
Install
Download the sqlode escript below and place it on your PATH.
Requires Erlang/OTP runtime.
chmod +x sqlode
./sqlode generate --config=sqlode.yamlSHA256SUMS is signed with cosign (SHA256SUMS.sigstore.json), and SLSA provenance is attached. See "Verifying release integrity" in the README.