Skip to content

Conversation

@djerius
Copy link
Contributor

@djerius djerius commented Aug 4, 2025

Tables and columns were not properly quoted in all instances when the
quote_char constructor option is set. Some were underquoted, some over quooted,
and some table expressions were quoted. This lead iin the latter cases to illegal SQL.

The intrinsic problem lies with treating them as strings, rather than
as objects, so there is no "quote" or "quotable" state assigned to a
given SQL fragment. The code has to rely upon heuristics to know when
to quote (e.g. a bare identifier) and when not to quote (interpolation
of an SQL expression). This requires carrying external state (e.g.,
the new is_literal flag from _parse_table and in the return from
table_alias), and informing the quoting apparati in table_alias() and
column_alias() of whether quoting is permissible via the "quote_name"
and "quote_aliased_name" options.

djerius added 2 commits August 4, 2025 14:11
change from double to single quotes in 01-sql_abstract_more_quoted.t
to make it easier to compare with 08-sql_abstract_more_quoted.t

add test for literal sql in joins with  using()

add test for CTE
Tables and columns were not properly quoted in all instances when the
quote_char constructor option is set.  Some were underquoted, some over quooted,
and some table expressions were quoted.  This lead iin the latter cases to illegal SQL.

The intrinsic problem lies with treating them as strings, rather than
as objects, so there is no "quote" or "quotable" state assigned to a
given SQL fragment.  The code has to rely upon heuristics to know when
to quote (e.g. a bare identifier) and when not to quote (interpolation
of an SQL expression).  This requires carrying external state (e.g.,
the new is_literal flag from _parse_table and in the return from
table_alias), and informing the quoting apparati in table_alias() and
column_alias() of whether quoting is permissible via the "quote_name"
and "quote_aliased_name" options.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant