Repository navigation
feat(session): track sql_mode per session; name @@var columns as written - #57
Merged
Merged
Conversation
SET [SESSION] sql_mode = <literal | DEFAULT | expression over @@sql_mode | ?> is recorded by the session and read back by SELECT @@sql_mode; @@global stays ''. Recorded, not enforced (warning). @@SESSION.x / @@GLOBAL.x are parsed case-insensitively (@@SESSION.sql_mode used to read a variable named SESSION and return NULL) and result columns are named as written or by alias, as MySQL does. Select lists mixing @@vars with other items go to the parser instead of being answered with only the variables. Documents the non-strict differences (empty string in INTEGER columns stays text; bare GROUP BY columns; MIN/MAX bare-column rule differs between SQLite and Turso) with the coercion decision, pinned by tests/mysql_sql_mode.rs.
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.
sql_mode
SET [SESSION|LOCAL] [@@[session.]]sql_mode {=|:=} <value>is recorded per session. The value can be a literal,DEFAULT, any expression (evaluated with the current mode substituted for@@sql_mode, soREPLACE(@@sql_mode, 'ONLY_FULL_GROUP_BY', '')works), or a bound?(prepared path).SELECT @@sql_mode/@@SESSION.sql_modereads the recorded value back.@@GLOBAL.sql_modeis always'', andSET GLOBAL|PERSISTchanges nothing on the connection, as on MySQL.'', because litewire enforces none of MySQL 8.4's default modes; reporting them would claim checks that never happen.@@variables
@@SESSION.x/@@GLOBAL.x/@@LOCAL.xare parsed case-insensitively. Bug fixed:SELECT @@SESSION.sql_modeused to read a variable namedSESSIONand return NULL.@@SESSION.sql_mode) or by their alias, because PHP reads$row['@@sql_mode'].@@varswith anything else (SELECT @@version, NOW()) goes to the parser. Previously everything except the variables was silently dropped.select @@version_comment limit 1(the mysql CLI's connect probe) still works.Documented and pinned: non-strict differences
These were measured over the wire on rusqlite and Turso and compared against MySQL 8.4.11. The comparison table and the decision are in
docs/sql-translation.mdunder "sql_mode", andtests/mysql_sql_mode.rspins them.n = 0is false,n > 5is true, ORDER BY sorts it after every number, andSUM/n + 1treat it as 0. No coercion for now: the translator does not know column types. The doc describes the schema-aware session approach as a follow-up.GROUP BYcolumns come from the first row in scan order on both engines. With MIN/MAX in the select, SQLite and Turso differ: SQLite applies its min/max bare-column rule and Turso does not.