Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with Aliasing columns with with sql keywords #2738

Open
MalkaSteinberg opened this issue May 2, 2023 · 1 comment
Open

Problem with Aliasing columns with with sql keywords #2738

MalkaSteinberg opened this issue May 2, 2023 · 1 comment

Comments

@MalkaSteinberg
Copy link

MalkaSteinberg commented May 2, 2023

Version: 4.6.0:
Module: quill-jdbc:
Database: Sql Server:

I have a field in my table name 'TO'. When running a select statement quill runs this:
select a."to" as to from email a

I would expect that quill would wrap the to as follows:
select a."to" as [to] from email a

quill should be responsible for escaping reserved sql words.

@getquill/maintainers

@joelsonoda
Copy link
Contributor

joelsonoda commented Jun 30, 2023

@MalkaSteinberg , I don't know if you found a workaround for this, but in our projects we have extended the context

trait NamingSqlServerJdbcContext extends SqlServerJdbcContext:

  override def tokenizeColumnAlias(strategy: NamingStrategy, column: String): String =
    strategy.column(column)

  override def tokenizeFixedColumn(strategy: NamingStrategy, column: String): String =
    strategy.column(column)

  override def tokenizeTableAlias(strategy: NamingStrategy, table: String): String =
    strategy.table(table)

  override def tokenizeIdentName(strategy: NamingStrategy, name: String): String =
    strategy.default(name)

If the naming strategy doesn't quote the column alias, fixed column and table alias, those should be quoted as well.

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

No branches or pull requests

2 participants