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
I'm testing tbls against a schema with a reserved name (time) as well as with a hyphenated table name:
CREATESCHEMAtime;
CREATETABLEtime.bar (
id int IDENTITY(1, 1) PRIMARY KEY
);
CREATETABLEtime."hyphenated-table" (
id int IDENTITY(1, 1) PRIMARY KEY
);
CREATETABLEtime.referencing (
id int IDENTITY(1, 1) PRIMARY KEY,
bar_id intNOT NULL,
ht_id intNOT NULL,
CONSTRAINT referencing_bar_id FOREIGN KEY(bar_id) REFERENCEStime.bar(id),
CONSTRAINT referencing_ht_id FOREIGN KEY(ht_id) REFERENCEStime."hyphenated-table"(id)
);
While foreign keys are not enforced by Redshift, the query optimiser does use them so it makes sense to put these in.
The above schema breaks tbls' relations parsing, because it doesn't account for the quoting that AWS redshift puts on both the schema and on the second table, when querying constraints:
select pg_get_constraintdef(oid) as def from pg_constraint
where conrelid ='time.referencing'::regclass and contype ='f';
def
-----------------------------------------------------FOREIGN KEY (bar_id) REFERENCES"time".bar(id)
FOREIGN KEY (ht_id) REFERENCES"time"."hyphenated-table"(id)
(2 rows)
Note the "time" quoting in the response, and the separate quotes around hyphenated-table.
What happened
I'm testing tbls against a schema with a reserved name (
time
) as well as with a hyphenated table name:While foreign keys are not enforced by Redshift, the query optimiser does use them so it makes sense to put these in.
The above schema breaks tbls' relations parsing, because it doesn't account for the quoting that AWS redshift puts on both the schema and on the second table, when querying constraints:
Note the
"time"
quoting in the response, and the separate quotes aroundhyphenated-table
.This causes tbls to be unhappy, because the postgres driver only strips quotes from the start and end of the string
With
DEBUG=1
we thus see:Perhaps a more sophisticated quote removal routine is needed?
Environment
tbls version
: 1.35.0The text was updated successfully, but these errors were encountered: