-
Notifications
You must be signed in to change notification settings - Fork 120
Closed
Milestone
Description
Following insertOrSkip() of #942
INSERT ... ON DUPLICATE UPDATE
- ✅ MySQL: Native support
⚠️ PostgreSQL: Need to specify which column(s) cause the conflict⚠️ SQLite: Need to specify conflict column(s), requires 3.24.0+⚠️ SQL Server: Very complex MERGE syntax
Database Support Matrix
| Feature | MySQL/MariaDB | PostgreSQL | SQLite | SQL Server |
|---|---|---|---|---|
| INSERT IGNORE | ✅ Native | ✅ Via ON CONFLICT DO NOTHING | ✅ Via INSERT OR IGNORE | ❌ No native support |
| INSERT ... ON DUPLICATE KEY UPDATE | ✅ Native | ✅ Via ON CONFLICT ... DO UPDATE | ❌ Limited |
We can still add insertOrUpdate() if people are interested in this.
- Start with single-row upserts
- Require explicit conflict columns for now (avoid auto-detection complexity)
- Consider it a "power user" feature for data sync scenarios
For SQLite and SQLServer we might want to "shim" it using the old way internally, so it doesnt need to throw NotImplementedExceptions.
This would still gain performance for Mysql and Postgres.
What do you think?
Example future use:
// Seed with updates - sync from external API
$this->insertOrUpdate('currencies', [
['code' => 'USD', 'rate' => 1.0000, 'updated' => '2025-11-04'],
['code' => 'EUR', 'rate' => 0.9234, 'updated' => '2025-11-04'],
], ['rate', 'updated'], ['code']); // Update rate+updated if code existsMetadata
Metadata
Assignees
Labels
No labels