-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Issue 12729 postgresql duplicate key value #13721
Issue 12729 postgresql duplicate key value #13721
Conversation
b028a95
to
f9f6994
Compare
3b32300
to
c621585
Compare
Code wise makes a lot of sense. 👍 Let me test this later and then I'm fine with getting this in. |
Please add |
We need to be careful here as it is then a public API we need to keep stable. Maybe we add some PHPDoc to indicate that this is not fully finished and should not be used for now? Maybe we find some cases in the near future where we need to change the API a little bit. |
Is not adding the method to the interface an option? Technically it works 🤔 |
I would prefer to add the "on conflict" handing to the query builder |
Then query builder has to know which adapter is used by the current connection. Would you prefer to a) introduce child classes
I guess both ways have their pros/cons. Maybe you come up with a better idea. |
You can already determine the sql backend used within the query builder, see the but since this probably makes most sense in the QueryBuilder itself and not a "sub builder" subclassing the QueryBuilder is probably best |
c621585
to
1b1231c
Compare
I finally found time to get back to this, thanks for staying with me. I applied the proposed changes to the existing approach, meaning
Though I am interested in the approach of adding it to the QueryBuilder. How would that work, would I just add a function 'upsert' or 'updateIgnoreConflict' to the QueryBuilder that builds the proposed query, and calls the Adapter to build/add the database-specific part to the query? The this could be used directly in the DBLockingProvider. |
foreach($values as $key => $value) { | ||
$builder->setValue($key, $builder->createNamedParameter($value)); | ||
} | ||
$queryString = $builder->getSQL() . ' ON CONFLICT DO NOTHING'; |
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.
With which version of Postgres does this work? I only can find it in the docs since Postgres 9.5.
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.
Aye. Caused this regression: #15613
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.
😢
Code looks good so far. @icewind1991 Mind to test this? |
1b1231c
to
c0982f7
Compare
c0982f7
to
86f607c
Compare
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.
I'm fine with this change 👍
@oole Do you mind to rebase on the latest master because we fixed some failing tests there. |
…file locking. Signed-off-by: Ole Ostergaard <ole.c.ostergaard@gmail.com>
Signed-off-by: Ole Ostergaard <ole.c.ostergaard@gmail.com>
Signed-off-by: Ole Ostergaard <ole.c.ostergaard@gmail.com>
Signed-off-by: Ole Ostergaard <ole.c.ostergaard@gmail.com>
Signed-off-by: Ole Ostergaard <ole.c.ostergaard@gmail.com>
86f607c
to
0d778fc
Compare
Happy to read! Of course, rebased and pushed. |
What about #13721 (comment) ? Afaik, 9.4 is still suppported until end of this year. |
This comment has been minimized.
This comment has been minimized.
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
I pushed a fix for this. Was a missing |
@kesselb @rullzer @ChristophWurst Mind to review? I would like to get this into beta 1 to have as much test coverage as possible. |
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.
Lets do this. And test the hell out of it in real life as well 🚀 🐘
Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22 |
This should fix the
ERROR: duplicate key value violates unique constraint "lock_key_index"
errors filling up the PostgreSQL log. As described by Issue 12729.
I moved the insert statement from the DBLockingProvider.php to the Adapter.php, so that database specific inserts are possible.