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
Since Npgsql supports Redshift (see Server Compatibility Mode connection string parameter accepted values, which include Redshift), then EntityFramework6.Npgsql should support Redshift too. However, this is not the case.
To reproduce, connect to a Redshift cluster and create a table with a varchar column. Then try to query it through EF using a string literal to match on that column. For example:
var data = myContext.MyTable.Where(c => c.MyVarcharColumn == "foo").ToArray();
Expected: get no results or some results.
Actual: exception is thrown (42704: type "e" does not exist) because generated SQL statement has a syntax error. Notice that "E" before opening single quote in string literal in generated SQL below:
SELECT "Extent1"."MyVarcharColumn" FROM "dbo"."MyTable" WHERE E'foo' = "Extent1"."MyCarcharColumn"
The text was updated successfully, but these errors were encountered:
The E' syntax was introduced a long time ago, but since Redshift is based on an ancient PostgreSQL version, it doesn't support all features.
You could workaround that by putting "foo" in a local variable, and refer to that in your linq query. That will make EF use a parameter instead of a literal.
The Npgsql project made code changes to support Redshift. It did not wait for Redshift to eventually become compatible with it. Why can't this project do the same?
If I remember correctly, the reason for the E' syntax is that it it's consistent how it works. Only using ' and ' had the issue that it was configurable (or maybe different between pg versions) how the escaping was done.
Since Npgsql supports Redshift (see
Server Compatibility Mode
connection string parameter accepted values, which includeRedshift
), thenEntityFramework6.Npgsql
should support Redshift too. However, this is not the case.To reproduce, connect to a Redshift cluster and create a table with a
varchar
column. Then try to query it through EF using a string literal to match on that column. For example:var data = myContext.MyTable.Where(c => c.MyVarcharColumn == "foo").ToArray();
Expected: get no results or some results.
Actual: exception is thrown (
42704: type "e" does not exist
) because generated SQL statement has a syntax error. Notice that "E" before opening single quote in string literal in generated SQL below:The text was updated successfully, but these errors were encountered: