-
Notifications
You must be signed in to change notification settings - Fork 214
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
Add support for "FOR UPDATE" and "SKIP LOCKED" #62
Conversation
Let me know if you like this direction, and I'll flesh out tests and the other ForSomething methods. |
Oh and this doesn't yet support the "OF table_name" optional bit of a FOR clause. |
default_limit_fragment = []byte(" LIMIT ") | ||
default_offset_fragment = []byte(" OFFSET ") | ||
default_for_update_fragment = []byte(" FOR UPDATE ") | ||
default_for_no_key_update_fragment = []byte(" FOR NO KEY UPDATE ") |
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.
This doesn't seem universally supported. Does a downstream user just override this if their rdbms uses different syntax?
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.
Not sure. Mysql and Postgres both support it. The only other DB in goqu's adapters folder is sqlite3, which lacks lots of stuff the others support.
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.
Also, it's an opt-in feature. If you write a query using it and your DB doesn't support it, you'll just get an error when trying to run the query. You'll then just have to rewrite your query to not use the feature that your DB doesn't support.
Codecov Report
@@ Coverage Diff @@
## master #62 +/- ##
=========================================
- Coverage 82.98% 82.2% -0.79%
=========================================
Files 17 17
Lines 2087 2119 +32
=========================================
+ Hits 1732 1742 +10
- Misses 247 268 +21
- Partials 108 109 +1
Continue to review full report at Codecov.
|
@btubbs this looks good if you want to go ahead and add tests for the base adapter and the implemented adapters I can get this merged and released |
Cool. I'll try to get that out this week. |
I added the other methods, and tests. |
@doug-martin could you please merge this feature, our project also depend on it |
@btubbs could you please tag your branch, this is allowed to use it at |
@arbrix I added the "for-update" tag. Will that work? |
This addresses #43. It's a first stab, but hopefully close.
The public interface only exposes a .ForUpdate() method on the dataset for now, but under the hood it's built to support .ForNoKeyUpdate(), .ForShare(), and .ForKeyShare() as well.