-
-
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
Declare InQuery Variables #184
Comments
@ahmad-moussawi Please take a look when you have a chance. |
I already have the code to build just the declaration part for MySQL, SQL Server, and SQLite but the challenge would be the Where conditions. Let's review how can we generate the code. For SQLite, I look in StackOverflow and I found this answer . In order to declare variables for SQLite, we can do it like in the listing 1.1 Listing 1.1
I think we can handle this in the method Compiler.PrepareResult and the SqlResult.ToString to replace the generated "p0X" variables to the custom define variables. For PostgreSQL there is a way to build declarations, I didn't test it but base on this answer we can use something like in the listing 1.2 listing 1.2
solution for SQLIte Conclusion |
Hi @ahmad-moussawi
but why you want to declare the inline var in raw sql and get very platform specific code? I hope, that we need only replace 'unnamed' @p... params to named in binding collection,
should be compiled on every platform to
with bindings collection is [{@Date, 2019-05-08 12:10:00}] |
@mota57 thank you for the informative research, as you've mentioned Oracle, SQLite and Postgres seem that they don't support a direct way of variable declaration, and the provided solutions would add unwanted complexity. so sticking to the previous approach you were working on is the best for now (same example provided by @for7raid). |
Hey @ahmad-moussawi, as @for7raid said we might need to replace @px and I did that for a simple query but also I will have to test it each function at Compiler.Condition.cs to make sure it works for every case. I still have to figure it out how to build the binding collection, I didn't know that was possible without a declaration.
|
@mota57 your last picture is not I mean
goes to
and compile returns binsings |
@for7raid thanks for the information I did some changes based on what you said, I add the variables to the binding property, I removed the declaration part, I tested what I have with methods like WhereIn, WhereRaw, Where, OrWhere, WhereIn and with nested conditions. So, it works but I have to make a couple more changes and complete the test cases in order to upload a new branch. Update
but not like this
|
@mota57 amazing, if you need any help/assistance let us know. |
@ahmad-moussawi ready |
@mota57 thanks for the update, appreciate it, I will review it soon and get back to you |
@ahmad-moussawi |
I'm curious if there's any update on this? |
no idea, I remember I move my code but at end never went to production. |
Actually it's available in the latest prerelease. |
oh i didnt know that, thanks for letting me know.
…On Tue, Jan 21, 2020, 1:02 PM Ahmad Moussawi ***@***.***> wrote:
Actually it's available in the latest prerelease.
Working on the documentation before the official release.
A big thanks for @mota57 <https://github.com/mota57>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#184?email_source=notifications&email_token=ABZYERP5LAKVEE6ME3SRPZLQ64TD7A5CNFSM4GPEYTY2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEJQPIPY#issuecomment-576779327>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABZYERMC35IBDA2BLBRCFWTQ64TD7ANCNFSM4GPEYTYQ>
.
|
So this was never merged? I see no traces of WithVar() anywhere in the api. Was there ever another way introduced? |
Add the ability to declare variables for the query especially when the variable is used more than once.
The text was updated successfully, but these errors were encountered: