CSNW / sql-bricks

Transparent, Schemaless SQL Generation
http://csnw.github.io/sql-bricks
MIT License
204 stars 25 forks source link

Upsert queries #83

Closed danturu closed 8 years ago

danturu commented 8 years ago

Does it support queries like INSERT INTO queries(...) VALUES(...) ON CONFLICT(...) DO update SET ...?

I see it in the documentation, but not in the source code.

prust commented 8 years ago

@rosendi:

I see it in the documentation, but not in the source code

The only similar things I can find in the docs are the on() method which is passed a join criteria object and only works with the JOIN methods (INNER JOIN ... ON ..., CROSS JOIN ... ON ..., etc), not with CONFLICT, and the orReplace() method which is how you do an upsert in the SQLite dialect. It has a lingering table of contents entry but has been removed from the documentation itself because it is now only available in the https://github.com/CSNW/sql-bricks-sqlite extension library.

It looks to me like the ON CONFLICT statement is postgres-specific. If so, it would belong in @Suor's postgres extension (https://github.com/Suor/sql-bricks-postgres) -- perhaps you saw something about it in his repo? (I looked, but didn't find anything)

danturu commented 8 years ago

@prust Thank you! You are correct, the statement is postgres-specific. I misunderstood the orReplace() method. Now I see that the issue is related to the sql-bricks-postgres package.