-
-
Notifications
You must be signed in to change notification settings - Fork 496
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
Curly Brackets compiled into Square Brackets: Request to disable column identifier #430
Comments
You should escape it with \ something like this should work
```
[\{\}]
```
…On Sat, Nov 21, 2020, 21:25 EyreC ***@***.***> wrote:
This works:
var query = new Query("tableName");
query.Select("id").WhereNot("title", "[{}]")
And yields:
SELECT id FROM tableName WHERE title != '[{}]'
However, curly braces in the SelectRaw or WhereRaw get compiled into
square brackets:
var whereRawQuery = new Query("tableName");
query.Select("id").WhereRaw("title != '[{}]')
This compiles into:
SELECT id FROM tableName WHERE title != '[[]]'
Equivalently the following also occurs:
Query selectBracket = new Query("tableName");
selectBracket.SelectRaw("id, (select id, title from otherTable where title != '[{}]' for json path) ");
This compiles into:
SELECT id (select id, title from otherTable where title != '[[]]' for json
path) FROM tableName
Note the '[{}]' is now '[[]]'.
My guess is that the has something to do with how SqlKata identifies
columns.If this is the case, would it be possible to optionally disable
this text replacement?
I am trying to persuade my organisation to use SqlKata more extensively,
but we'd likely still need to make use of the .Raw functions in SqlKata
while things get ported over.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#430>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AATGUE6GMP53264CGSUQG3DSRAH2TANCNFSM4T57CTZQ>
.
|
The backslash is not valid escape syntax for the curly brace in C# - I get a compile error attempting to use it. The escape sequence for a curly place is to duplicate it like this: Are you able to escape the curly brace @ahmad-moussawi ? If so, where and how do you do so? |
Yes check this #407 similar to your case. |
I've managed to do that, thank you @ahmad-moussawi |
This works:
And yields:
SELECT id FROM tableName WHERE title != '[{}]'
However, curly braces in the SelectRaw or WhereRaw get compiled into square brackets:
This compiles into:
SELECT id FROM tableName WHERE title != '[[]]'
Equivalently the following also occurs:
This compiles into:
SELECT id (select id, title from otherTable where title != '[[]]' for json path) FROM tableName
Note the '[{}]' is now '[[]]'.
My guess is that the has something to do with how SqlKata identifies columns.If this is the case, would it be possible to optionally disable this text replacement?
I am trying to persuade my organisation to use SqlKata more extensively, but we'd likely still need to make use of the .Raw functions in SqlKata while things get ported over.
The text was updated successfully, but these errors were encountered: