You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(data-grid): distinguish literal string 'NULL' from SQL NULL in TableMutationEngine WHERE clause #1368
In TableMutationEngine._buildWhereClause (lib/core/database/table_mutation_engine.dart, lines 487 and 504):
final val = row[colIdx];
if (val =='NULL'|| val =='null') {
clauses.add('$colName IS NULL');
} else {
final colType =_lookupDataType(columnDataTypes, matchedCol) ??_lookupDataType(columnDataTypes, pk);
clauses.add('$colName = ${formatLiteral(val, dialect, dataTypeName: colType)}');
}
When building WHERE clauses for UPDATE and DELETE statements, _buildWhereClause unconditionally converts any column value equal to 'NULL' or 'null' to $colName IS NULL, ignoring whether the column is text-based (_isTextType) and bypassing TableMutationEngine.kNullSentinel.
Impact (Data Corruption / Data Loss Risk)
If a table contains a text column (e.g. code, status, notes, or a text primary key) with the literal string value "NULL":
Modifying that row in the Virtual Data Grid generates: UPDATE "users" SET "name" = 'Bob' WHERE "code" IS NULL;
instead of: UPDATE "users" SET "name" = 'Bob' WHERE "code" = 'NULL';
If another row in the database has an actual NULL in that column, that other row is silently modified!
If the user deletes the row, DELETE FROM "users" WHERE "code" IS NULL; deletes the wrong row(s).
If no row has NULL, the mutation silently affects 0 rows.
Scope
In TableMutationEngine._buildWhereClause, check _isTextType(colType) before treating 'NULL' / 'null' as SQL NULL.
Ensure kNullSentinel (\u0000__QUERYA_NULL__\u0000) is used to unambiguously identify genuine SQL NULL values across staging buffers and mutation generation.
Add regression tests in test/core/database/table_mutation_engine_test.dart for rows containing literal 'NULL' strings in text columns and primary keys.
Out of scope
UI cell editor styling for NULL vs empty string (already handled).
Activity
ZhuchkaTriplesix commentedon Oct 11, 2026
Done in #1385 (merged into
dev).