Skip to content

Conversation

@deusaquilus
Copy link
Collaborator

@deusaquilus deusaquilus commented Nov 24, 2024

In on-conflict queries where the "existing" column is used in multiple clauses and aliased with different names the 2nd etc... aliases are invalid because they don't even exist. For the excluded references, the EXCLUDED term should be used but for the "existing" column nothing should be used at all.

 ins.onConflictUpdate(_.i, _.s)(
    (t, e) => t.l -> foo(t.l, e.l), (tt, ee) => tt.l -> bar(tt.l, ee.l)
  )

// (Scroll right ->)
//                                                                                                                            This doesn't exist!!
//                                                                                                                                    v
// > INSERT INTO TestEntity AS t (s,i,l,o,b) VALUES (?, ?, ?, ?, ?) ON CONFLICT (i,s) DO UPDATE SET l = foo(t.l, EXCLUDED.l), l = bar(tt.l, EXCLUDED.l)

Instead we should completely drop the table name and just use the column:

INSERT INTO TestEntity AS t (s,i,l,o,b) VALUES (?, ?, ?, ?, ?) 
ON CONFLICT (i,s) 
DO UPDATE SET l = foo(/*-- drop: t. --*/ l, EXCLUDED.l), l = bar(/*-- drop: tt. --*/ l, EXCLUDED.l)

@deusaquilus deusaquilus merged commit dd814f1 into master Nov 24, 2024
13 checks passed
@deusaquilus deusaquilus deleted the onconflict_case_fix branch November 24, 2024 06:42
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.

2 participants