-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQLite Query: Translate string.Join and Concat #28100
Comments
I've already added some custom aggregate translations for Npgsql (npgsql/efcore.pg#2383), I can probably do the above along with #2981. |
Note slight discrepancy between string.Join and group_concat, as group_concat filters out nulls but the string.Join doesn't - you get an empty string. So to get a faithful translation, we'd need to coalesce to empty string. Same thing happens on SQL Server and PG string_agg. |
Poaching (in case it wasn't abundantly clear 😅) |
Same as SQL Server (#2981 (comment)): Null semantics of group_concatDROP TABLE IF EXISTS data;
CREATE TABLE data
(
id INT PRIMARY KEY,
name TEXT
);
-- Simple sample
INSERT INTO data (name) VALUES ('foo'), ('bar');
SELECT group_concat(name, ', ') FROM data; -- foo, bar
-- NULLs are ignored and the corresponding separator is not added
DELETE FROM data WHERE 1=1;
INSERT INTO data (name) VALUES ('foo'), (NULL), ('bar');
SELECT group_concat(name, ', ') FROM data; -- foo, bar
-- NULLs only results in NULL
DELETE FROM data WHERE 1=1;
INSERT INTO data (name) VALUES (NULL);
SELECT group_concat(name, ', ') FROM data; -- NULL
-- Empty table results in NULL
DELETE FROM data WHERE 1=1;
SELECT group_concat(name, ', ') FROM data; -- NULL |
Duplicate of #2981 |
Doing this as part of #2981 |
These can be translated into the
group_concat
aggregate function.The text was updated successfully, but these errors were encountered: