-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Support database schemas with spaces and dashes #2173
Support database schemas with spaces and dashes #2173
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for working on this. I've left some comments.
Additionally I would like to see a test case that uses a reserved keyword as table name.
Beside of that: Should we do the same thing also for table schemas?
1a87391
to
cd1ca8a
Compare
cd1ca8a
to
9862026
Compare
Sorry for taking a while to get back to this, real life has been hitting me hard this month. 🙂 I had a look at doing the same for table schemas but was a bit unsure how to go about implementing it. If you think it's worth getting that in with this PR as well then I can have another go at it, any pointers would definitely help! 😄 |
96d5a1f
to
eec65fa
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now I needed some time for other stuff 🙈
Anyway the PR looks quite good now, I've found only a few minor things where the code could be improved.
- Using rust_name where appropriate - Added test to ensure schema names are still included where appropriate
eec65fa
to
624718c
Compare
915e53e
to
bff0cd8
Compare
@@ -14,7 +14,9 @@ static RESERVED_NAMES: &[&str] = &[ | |||
"type", "typeof", "unsafe", "unsized", "use", "virtual", "where", "while", "yield", | |||
]; | |||
|
|||
fn is_reserved(name: &str) -> bool { | |||
static UNMAPPABLE_CHARS: &[char] = &['-', ' ']; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SQL table names can use other characters that would not translate well to a Rust identifier (e.g., a colon :
).
Rust identifiers are restricted to [a-z A-Z 0-9 _]
, so I think that a more robust approach would be to map any character outside of this range to an underscore.
Closes #2168
I had a few issues in setting up my environment this weekend to be able to properly test the functionality past the unit test so I took a few assumptions on where sql names would be used over rust variable names (e.g. in
joinable!
andallow_tables_to_appear_in_same_query!
).Let me know if they need to be changed or if there are any other changes needed to complete this PR, thanks.