-
Notifications
You must be signed in to change notification settings - Fork 55
Add ignore param to createDocuments for silent duplicate handling #851
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
Changes from 2 commits
287420b
2b4fd1e
37aace4
9653052
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1365,6 +1365,35 @@ public function updateDocument(Document $collection, string $id, Document $docum | |||||||||||||||||||||
| return $document; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| protected function getInsertKeyword(bool $ignore): string | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| return 'INSERT INTO'; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| protected function getInsertSuffix(bool $ignore, string $table): string | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| if (!$ignore) { | ||||||||||||||||||||||
| return ''; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| $conflictTarget = $this->sharedTables ? '("_uid", "_tenant")' : '("_uid")'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return "ON CONFLICT {$conflictTarget} DO NOTHING"; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| protected function getInsertPermissionsSuffix(bool $ignore): string | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| if (!$ignore) { | ||||||||||||||||||||||
| return ''; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| $conflictTarget = $this->sharedTables | ||||||||||||||||||||||
| ? '("_type", "_permission", "_document", "_tenant")' | ||||||||||||||||||||||
| : '("_type", "_permission", "_document")'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return "ON CONFLICT {$conflictTarget} DO NOTHING"; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+1373
to
+1395
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Both
Actual unique indexes vs. conflict targets:
The fixes: // getInsertSuffix – main document table
protected function getInsertSuffix(bool $ignore, string $table): string
{
if (!$ignore) {
return '';
}
$conflictTarget = $this->sharedTables
? '("_uid" COLLATE utf8_ci_ai, "_tenant")'
: '("_uid" COLLATE utf8_ci_ai)';
return "ON CONFLICT {$conflictTarget} DO NOTHING";
}
// getInsertPermissionsSuffix – permissions table
protected function getInsertPermissionsSuffix(bool $ignore): string
{
if (!$ignore) {
return '';
}
$conflictTarget = $this->sharedTables
? '("_type", "_permission", "_document", "_tenant")'
: '("_document" COLLATE utf8_ci_ai, "_type", "_permission")';
return "ON CONFLICT {$conflictTarget} DO NOTHING";
}Without this fix,
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The existing upsertDocuments at [Postgres.php:1462] uses ("_uid") without COLLATE and works in production |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| /** | ||||||||||||||||||||||
| * @param string $tableName | ||||||||||||||||||||||
| * @param string $columns | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.