question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unless conflict does not work on two-field indexes?

See original GitHub issue

I get this error with UNLESS CONFLICT ON (.field1, .field):

edgedb.errors.QueryError: ON CONFLICT argument must be a property

And this error on UNLESS CONFLICT ON .field1, .field2:

edgedb.errors.EdgeQLSyntaxError: Unexpected ','

I.e. it look like not a bug, but just syntactically incorrect

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
elpranscommented, Mar 6, 2021

@Mulugruntz, this is currently set for the 1.0 milestone, but chances are we can get support for matching constraints with expressions in UNLESS CONFLICT into the next beta.

2reactions
msullivancommented, Mar 2, 2021

Oh, I had meant to update this: we don’t yet support a direct syntax for this, but there is a simple workaround: use a computed property.

So with a schema like

type Entry {                                                              
    required property field1 -> str;                                      
    required property field2 -> int64;                                    
    required property field3 -> bool;                                     
    property key {                                                        
        using ((.field1, .field2));                                       
        constraint exclusive;                                             
    };                                                                    
}

You can do queries like

INSERT Entry { field1 := "test", field2 := 42, field3 := false } 
UNLESS CONFLICT ON (.key)
ELSE (UPDATE Entry SET { field3 := true });
Read more comments on GitHub >

github_iconTop Results From Across the Web

Why PostgreSQL's ON CONFLICT Cannot Find My Partial ...
If the index used in ON CONFLICT() is a partial index, predicates of the index (WHERE …) must be added after the ON...
Read more >
postgresql - Use multiple conflict_target in ON CONFLICT clause
ON CONFLICT requires a unique index* to do the conflict detection. So you just need to create a unique index on both columns:...
Read more >
ON CONFLICT on two columns where one can be null
I'm trying to use ON CONFLICT on two columns where one can be null . Unfortunatelly with partial index I don't seem to...
Read more >
Dropping index due to conflict with - how to solve related issues
This automatic process may have disadvantages, such as mapping conflicts, duplicate data and incorrect data types being set in the index. If the...
Read more >
UPSERT ON CONFLICT enhancement - SQLite Forum
Sometimes the "indexed-column" list in UNIQUE constraints can be ... run into a differentation problem if there where multiple columns in ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found