Skip to content
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

Atomic Increment? #488

Closed
adhip94 opened this issue Jun 1, 2021 · 4 comments
Closed

Atomic Increment? #488

adhip94 opened this issue Jun 1, 2021 · 4 comments

Comments

@adhip94
Copy link

adhip94 commented Jun 1, 2021

Anyone has tried atomic increment? For example is it possible to write the below query using SQLKata querybuilder:

update mytable
set readcount = readcount + 1 
where myid = '123456'
@adhip94 adhip94 closed this as completed Jun 8, 2021
@ahmad-moussawi
Copy link
Contributor

@adhip94 why you have closed this?

@adhip94
Copy link
Author

adhip94 commented Jun 8, 2021

I didnt get any reply from anyone, and it was urgent since 1 week had passed, hence after discussing with a colleague I got a solution that worked.

var query = new Query("mytable")
  .Where("myid", "123456")
  .AsUpdate(new {
    readcount = new UnsafeLiteral("readcount  + 1"),
  });

Also FYI, when I run the above query in the SQLKata Playgrounds page, I get this.
image

@ahmad-moussawi
Copy link
Contributor

Yes the UnsafeLiteral will help in this case, but this is an interesting feature to implement, I will reopen the issue.

Thanks for pointing out for the Playground issue, just fixed it.

@ahmad-moussawi ahmad-moussawi reopened this Jun 8, 2021
@ahmad-moussawi
Copy link
Contributor

This feature is now supported in 2.3.4 see #490 #489

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants