Skip to content

feat(db): add conflict tolerant inserts to query builder and QBMapper - #64772

Draft
Koc wants to merge 1 commit into
masterfrom
feature/insert-ignore-conflicts
Draft

Koc wants to merge 1 commit into
masterfrom
feature/insert-ignore-conflicts

Conversation

@Koc

@Koc Koc commented Sep 25, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds IQueryBuilder::ignoreConflictsOnInsert() to mark an INSERT as
    conflict tolerant. The SQL rewrite happens in getSQL() via a new
    Adapter::getInsertIgnoreSqlTransformer() (INSERT IGNORE for
    MySQL/MariaDB, ON CONFLICT DO NOTHING for PostgreSQL/SQLite, plain
    INSERT as fallback), so typed parameters and shard-key hints survive.
  • Refactors Adapter*::insertIgnoreConflict() to use the flag instead of
    editing the SQL string and calling the connection directly.
  • Adds QBMapper::insertIgnoreConflict(Entity $entity): int, porting the
    capability of the Collectives TInsertIgnoreConflict trait into core,
    returning the number of inserted rows (0 when a conflicting row exists).

Tests

  • tests/lib/DB/QueryBuilder/QueryBuilderTest.php: SQL transform per
    platform, end-to-end conflict insert, LogicException on non-INSERT.
  • tests/lib/AppFramework/Db/QBMapperTest.php / QBMapperDBTest.php:
    typed parameter mapping, conflict returns 0 without overwriting the row.

Checklist

AI (if applicable)

  • The content of this PR was partly or fully generated using AI

Signed-off-by: Kostiantyn Miakshyn <molodchick@gmail.com>

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

1 participant