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
|| treats NULL as empty text: 'a' || NULL is 'a', and NULL || NULL is ''. In SQL-92 (and SQLite) a concatenation with a NULL operand is NULL.
Seen in the NIST SQL Test Suite run in yts812.sql (WHERE TX2 || TX3 IS NOT NULL counts 5 rows instead of 3). Reproduced on develop (38bf3c3):
alasql('CREATE TABLE x (a CHAR(2), b CHAR(2))');alasql("INSERT INTO x VALUES ('a', NULL), (NULL, NULL), ('a', 'b')");alasql('SELECT a || b AS c FROM x');// [{c: 'a'}, {c: ''}, {c: 'ab'}]alasql('SELECT COUNT(*) AS n FROM x WHERE a || b IS NOT NULL');// [{n: 3}]
Expected (SQL-92 and SQLite): NULL, NULL, 'ab', and a count of 1.
Breaking?
Yes. Code can rely on 'Mr ' || middle_name giving text when the middle name is missing. It belongs with the other NULL changes.
Activity