On 29/4/25 16:36, Laurenz Albe wrote:
On Tue, 2025-04-29 at 08:36 +1000, Tim Starling wrote:
My code would be like
function upsert( $table, $names, $values, $key, $set ) {
if ( $this->type === 'mysql' ) {
$conflict = 'ON DUPLICATE KEY UPDATE';
} els
On 28/4/25 23:30, Peter Geoghegan wrote:
You can use an alias for the target table name. Is it feasible to
require callers to prefix all field names with a generic table name
alias?
No, primarily because MySQL does not support such an alias.
-- Tim Starling
ured than that, but that
gives you the idea.
MediaWiki has supported MySQL's ON DUPLICATE KEY UPDATE since 2013,
and we've always had the conflict target parameter $key since then as
a helper for emulation. So it's trivial to produce either MySQL and
SQLite syntax.
-- Tim Starling
because
the client knows everything about the excluded row. Recall my example:
INSERT INTO t VALUES (1,1) ON CONFLICT (k) DO UPDATE SET v=v+1;
If I meant SET v=EXCLUDED.v+1 I would have just written v=2. The
default policy (in other DBMSes) follows by analogy from the
single-row case.
-- Tim Starling
someone here has an idea for a
workaround, I think this field name resolution policy is a total
blocker. We can implement upsert on MySQL and SQLite but on PostgreSQL
it will remain emulated.
-- Tim Starling