-
Notifications
You must be signed in to change notification settings - Fork 210
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
Create select with comma macro to support negative number #663
base: main
Are you sure you want to change the base?
Create select with comma macro to support negative number #663
Conversation
Pull Request Test Coverage Report for Build 2722269177
💛 - Coveralls |
Oops. Thank you @ever0de . Let me change the separator as |
Let me try to find the workaround as much as possible I can. Until that, let me change this pr as draft |
We share some experimental results...
cc. @panarch |
conclusionmatch expression: Change expr -> literal Type converting: Implement trait - convert row value type(literal) to column value type As-istest!(
Ok(select!(
field_one | field_two
I64 | I64;
1 parse_i64("-1");
parse_i64("-2") 2;
3 3;
parse_i64("-4") parse_i64("-4")
)),
"SELECT field_one, field_two FROM Item"
); To-betest!(
Ok(select!(
field_one | field_two
I64 | I64;
1 | -1;
2 | 2;
3 | 3;
-4 | -4
)),
"SELECT field_one, field_two FROM Item"
); Note.to_owned, Date could be removed in the macro usage side code base @ever0de ? |
Description
For the better readability, gluesql uses select! macro.
But there is a nit problem. It can not handle consecutive negative numbers. That is why there are some workaround code - for example, parse_i64
Below code is the one example of workaound.
This is because macro rule can not handle consecutive negative numbers with whitespace separator. Here is the playground link
Suggestion
To solve this problem, It is good to use clear separator such as comma or bar instead of whitespace.
So I made a
select_with_comma
macro.