Skip to content

Commit 3f277c1

Browse files
github-actions[bot]claude-bot
authored andcommitted
(fix): CI — emit INSERT IGNORE when skipDuplicates is set in SQL::createDocuments
The MariaDB/MySQL/Postgres/SQLite adapters' shared createDocuments() always called $builder->insert(), ignoring the skipDuplicates flag. When Mirror::createDocuments forwarded a batch to destination under skipDuplicates (to backfill rows where source had INSERT IGNORE them as no-ops but destination still lacked them), destination crashed with PDOException 1062 Duplicate entry. Route through the query builder's insertOrIgnore() when skipDuplicates is true — it compiles to INSERT IGNORE (MySQL/MariaDB), INSERT OR IGNORE (SQLite), and INSERT ... ON CONFLICT DO NOTHING (Postgres). Fixes MirrorTest::testCreateDocumentsSkipDuplicatesBackfillsDestination.
1 parent 6f2fc7f commit 3f277c1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/Database/Adapter/SQL.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ public function createDocuments(Document $collection, array $documents): array
628628
$builder->set($row);
629629
}
630630

631-
$result = $builder->insert();
631+
$result = $this->skipDuplicates ? $builder->insertOrIgnore() : $builder->insert();
632632
$stmt = $this->executeResult($result, Event::DocumentCreate);
633633
$this->execute($stmt);
634634

0 commit comments

Comments
 (0)