Re: PostGres 9.5 Upsert

2016-02-01 Thread Ben Liyanage
Hey--that's pretty slick. I'm not sure when we're going to take a shot at this implementation, but I'll keep that in mind. -Ben On Mon, Feb 1, 2016 at 7:12 AM, wrote: > It should be possible to use a "RETURNING" clause to get the new row even > in the instance of a

Re: PostGres 9.5 Upsert

2016-02-01 Thread john . parton
It should be possible to use a "RETURNING" clause to get the new row even in the instance of a get_or_create. I occasionally use an UPDATE ... RETURNING query with Manager.raw to update a table and get modified instances in one shot. On Tuesday, January 12, 2016 at 12:54:03 PM UTC-6,

Re: PostGres 9.5 Upsert

2016-01-12 Thread bliyanage
After thinking about it a bit, I think the only function that would really benefit from this would be the update_or_create. If you're doing get_or_create you still need a second query to get the actual row. On Friday, January 8, 2016 at 4:13:26 PM UTC-8, bliy...@rentlytics.com wrote: > > Hey

Re: PostGres 9.5 Upsert

2016-01-10 Thread Anssi Kääriäinen
On Sun, Jan 10, 2016 at 5:22 PM, Sean Brant wrote: > I've always considered this a bug waiting to happen. I have seen many errors > with the get operation failing because it returned more then one value. > Usually you don't notice the error until you hit production. I

Re: PostGres 9.5 Upsert

2016-01-10 Thread Anssi Kääriäinen
On Sun, Jan 10, 2016 at 11:10 AM, Florian Apolloner wrote: > On Sunday, January 10, 2016 at 9:09:37 AM UTC+1, Anssi Kääriäinen wrote: >> >> The save() operation matches the semantics of upsert exactly - maybe we >> could use upsert there? > > Not sure .save() would be a

Re: PostGres 9.5 Upsert

2016-01-10 Thread Sean Brant
> On Jan 10, 2016, at 2:09 AM, Anssi Kääriäinen wrote: > > If I recall correctly, MySQL doesn't offer a way to specify on which index > you want to do the conflict resolution. This leads to problems - the upsert > might affect the wrong row if there are multiple unique

Re: PostGres 9.5 Upsert

2016-01-10 Thread Florian Apolloner
On Sunday, January 10, 2016 at 9:09:37 AM UTC+1, Anssi Kääriäinen wrote: > > The save() operation matches the semantics of upsert exactly - maybe we > could use upsert there? > Not sure *.save()* would be a good candidate for that. In the best case, *.save()* should execute one INSERT or

Re: PostGres 9.5 Upsert

2016-01-10 Thread Anssi Kääriäinen
If I recall correctly, MySQL doesn't offer a way to specify on which index you want to do the conflict resolution. This leads to problems - the upsert might affect the wrong row if there are multiple unique indexes on the table. PostgreSQL's version of upsert has a problem, too. It doesn't offer

Re: PostGres 9.5 Upsert

2016-01-09 Thread Cristiano Coelho
I agree! Also, does this already happen for the MySQL backend? MySQL has the insert on conflict update, that could work the same way. However, if I'm not wrong, the docs states that the above methods have a race condition (obvious since right now it does two operations), but if the code would

Re: PostGres 9.5 Upsert

2016-01-09 Thread Carl Meyer
On 01/08/2016 05:13 PM, bliyan...@rentlytics.com wrote: > Postgres 9.5 has added the functionality for UPSERT aka update or > insert. Any interest in aligning UPSERT on the db layer with the > get_or_create or update_or_create functionality in django? Sounds like > my company would be interested

Re: PostGres 9.5 Upsert

2016-01-08 Thread Florian Apolloner
Absolutely! On Saturday, January 9, 2016 at 1:13:26 AM UTC+1, bliy...@rentlytics.com wrote: > > Hey Guys, > > Postgres 9.5 has added the functionality for UPSERT aka update or insert. > Any interest in aligning UPSERT on the db layer with the get_or_create or > update_or_create functionality

PostGres 9.5 Upsert

2016-01-08 Thread bliyanage
Hey Guys, Postgres 9.5 has added the functionality for UPSERT aka update or insert. Any interest in aligning UPSERT on the db layer with the get_or_create or update_or_create functionality in django? Sounds like my company would be interested in doing the work if the PR will get the