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
PostgreSQL: renaming an attribute of a dj.U restriction quotes it with backticks #1638
On PostgreSQL, renaming an attribute in a projection of a dj.U restriction produces invalid SQL. (dj.U("b") & T).proj(c="b") compiles to SELECT DISTINCT `b` as "c" ...: the renamed attribute is quoted with MySQL backticks, which PostgreSQL rejects. MySQL returns the right rows.
The cause appears to be Heading.set_primary_key, which builds the new heading without table_info. The projection then quotes the attribute without the connection's adapter, and falls back to backticks.
Reproduction
DataJoint master, PostgreSQL 15:
importdatajointasdjschema=dj.Schema("scratch_u_proj")
@schemaclassT(dj.Manual):
definition=""" a : int32 --- b : int32 """T.insert([(1, 10), (2, 10), (3, 20)])
(dj.U("b") &T).proj(c="b").to_arrays("c")
# QuerySyntaxError: syntax error at or near "as"# LINE 1: SELECT DISTINCT `b` as "c" FROM "scratch_u_proj"."t"
On MySQL the same query returns [10, 20].
Expected behavior
The projection quotes every attribute for the connection's backend, and returns [10, 20] on PostgreSQL too.
Activity