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
ALTER TABLE "myschema.my_relations" ADD CONSTRAINT myschema.my_relations_test_field_length CHECK (length("test_field") <= 10)
Which fails with:
PG::SyntaxError: ERROR: syntax error at or near "." (ActiveRecord::StatementInvalid)
LINE 1: ...LE "myschema.my_relations" ADD CONSTRAINT myschema.my_relati...
^
The correct quoting of the table name is:
ALTER TABLE "myschema"."my_relations"
and the constraint name would reasonably be called myschema_my_relations_test_field_length. This can be achieved with:
Description
If I try and add a length constraint to a table whose name is given with an explicit schema, the generate SQL is not valid:
leads to:
Which fails with:
The correct quoting of the table name is:
and the constraint name would reasonably be called
myschema_my_relations_test_field_length
. This can be achieved with:but I think it would be nicer if
rein
handled this itself.ActiveRecord::ConnectionAdapters::PostgreSQL::Quoting#quote_table_name
seems like it solves some of the same issues - maybe it can be reused?Reproduction
Must be run with
PGUSER
andPGPASSWORD
set in the environment, and therein_schema_issue
DB already existingThe text was updated successfully, but these errors were encountered: