Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR here is somewhat a beginning of a conversation about how do we want to make proper sql identifiers when it comes to schemas, tables and columns, particularly for my use case I want this in order to use sql reserved words for table names. I'll try to split this into 2 logical parts:
How do we know how to escape depending on db variant?
A SQL 1999 rfc says that double quotes should be used in order to escape an identifier, nevertheless:
T
,SELECT * from t
will work,SELECT * from "t"
will notTherefore it felt logical to make an escaping mechanism based on
Dialect
. I didn't want to propagateDialectConfig
together withContext
down the call chain, it seemed to me kinda redundant, so I madeDialectConfig
part ofContext
. That's how we can access escaping mechanism in various places as long as you haveContext
How do we decide which table to escape?
With this PR I want to stick with tables, otherwise it can become too big. I see three options:
First options we already discarded as one that will change too much tests. As for a second option - I looked into lists of reserved words, and they are very different based on database, also it will not be fun to maintain them, that's why most of the libs resolve to escape all tables. Third option is most simple for now, since it will allow users to opt-in when they want/bump into this issue, also it will allow us to test mechanism first without changing all 1k+ tests, and perhaps we can start with option 3 and then eventually move to option 1. Therefore in this draft PR I made a flag in
Table
to opt in for escaping table name.Optional:
At the moment
DialectConfig
is kinda part of theDialect
, and I don't feel entirely good about including wholeDialect
inContext
. I kinda want to moveDialectConfig
into case class and make a separate implicit for it as a part ofDialect
so that when we need to constructContext
onlyDialectConfig
case class will be picked upIt is a draft PR yet, so obviously I haven't written tests for all cases, only for a simple
FROM
expression. This will follow when we come to consensus about the implementation.What do you guys think?
fixes #53