Open b-gyula opened 4 years ago
Version: 3.4.10 Module: quill-jdbc??? Database: PostrgeSQL
3.4.10
quill-jdbc
PostrgeSQL
Reserved words like "order" or "to" shall be aliased when generating SQL regardless the naming strategy.
Using "to" or any reserved word as name reference generates invalid SQL for PostgreSQL. E.g
for { order <- query[Ordr] to <- query[TradeOrdr].leftJoin(to => to.ordr == order.id) } yield (order)
Generates:
SELECT order.id, order.volume FROM ordr order LEFT JOIN trade_ordr to ON to.ordr_id = order.id
Both the "order" and "to" shall be aliased. Like
SELECT x1.id, x1.volume FROM ordr x1 LEFT JOIN trade_ordr x2 ON x2.ordr_id = x1.id
or
SELECT "order".id, "order".volume FROM ordr "order" LEFT JOIN trade_ordr "to" ON "to".ordr_id = "order".id
See this scastie as an example.
Might be related to Decouple identifier escaping from NamingStrategy
@getquill/maintainers
@b-gyula have you tried the NamingStrategy PostgresEscape?
PostgresEscape
val ctx = new SqlMirrorContext(PostgresDialect, PostgresEscape)
Version:
3.4.10
Module:quill-jdbc
??? Database:PostrgeSQL
Expected behavior
Reserved words like "order" or "to" shall be aliased when generating SQL regardless the naming strategy.
Actual behavior
Using "to" or any reserved word as name reference generates invalid SQL for PostgreSQL. E.g
Generates:
Both the "order" and "to" shall be aliased. Like
or
See this scastie as an example.
Might be related to Decouple identifier escaping from NamingStrategy
@getquill/maintainers