Closed bakasmarius closed 1 month ago
What! Is this some old PostgreSQL version? It looks like AS
is mandatory in PostgreSQL 7.2. In any case, I will add AS
to make sure this works everywhere. Thanks for reporting.
Fixed in kysely-codegen@0.16.2
!
I think it's because schema
and name
are reserved words, so you have to either use as
or use a non-reserved alias, for example, this works just fine:
select pg_namespace.nspname schemaa, pg_class.relname namee
from pg_inherits
join pg_class on pg_inherits.inhrelid = pg_class.oid
join pg_namespace on pg_namespace.oid = pg_class.relnamespace;
I think it's because
schema
andname
are reserved words, so you have to either useas
or use a non-reserved alias, for example, this works just fine:select pg_namespace.nspname schemaa, pg_class.relname namee from pg_inherits join pg_class on pg_inherits.inhrelid = pg_class.oid join pg_namespace on pg_namespace.oid = pg_class.relnamespace;
It works for me even without changing anything, so it could possibly be that an earlier PostgreSQL version treats reserved words differently. But that's good to know.
After installing 0.16.2, postgres-introspector.js
still contains the old query - maybe build
step had to be executed before the release?
I think it's because
schema
andname
are reserved words, so you have to either useas
or use a non-reserved alias, for example, this works just fine:select pg_namespace.nspname schemaa, pg_class.relname namee from pg_inherits join pg_class on pg_inherits.inhrelid = pg_class.oid join pg_namespace on pg_namespace.oid = pg_class.relnamespace;
It works for me even without changing anything, so it could possibly be that an earlier PostgreSQL version treats reserved words differently. But that's good to know.
I checked on a different DB where version is 15.4 and the old query works fine without the aliases, so yeah, looks like older versions treat reserved words differently.
After installing 0.16.2,
postgres-introspector.js
still contains the old query - maybebuild
step had to be executed before the release?
I will cry. I had some code that I had forgotten to deduplicate, so I changed the wrong file. I just installed knip and removed a bunch of unused files and variables β fixed in 0.16.3. π
After updating kysely-codegen to 0.16.0, I get this error:
β syntax error at or near "schema"
After digging into it, I found out that it's coming from a query in
PostgresIntrospector.#introspectPartitions
:Running it straight on the database (Postgres 13.5) produces a bit more informative error:
Adding
as
to aliases makes the error go away:I will submit a PR soon π
Upvote & Fund