Inline... On Tue, Nov 1, 2016 at 3:18 PM, Lukas Eder <[email protected]> wrote:
> Hi Samir, > > 2016-10-31 20:11 GMT+01:00 Samir Faci <[email protected]>: > >> Actually, the the second approach does work, though I was running into a >> different issue because the "primary key" in my case is serial ID which >> doesn't work well with upserts. >> >> I was wondering if there was a way to explicitly list the columns I want >> to use for upserts. >> >> Example: >> >> insert into pinned_tweets (user_handle, tweet_id, pinned_at) >> values ( >> 'rey', >> 1, >> clock_timestamp() >> )on conflict (user_handle)do update set (tweet_id, pinned_at) = (1, >> clock_timestamp())where pinned_tweets.user_handle = 'rey'; >> >> (Pulled from a random blog) >> > > Hmm, PostgreSQL ON CONFLICT will be supported in jOOQ 3.9: > https://github.com/jOOQ/jOOQ/issues/5297 > > Prior to 3.9, ON CONFLICT is already emulated via MySQL's ON DUPLICATE KEY > UPDATE syntax, in case of which the primary key (from your generated table) > will be passed to the ON CONFLICT clause. > > Let me know if this works for you. > Yup. That's what I was using. The issue I was running into was that the PKey was not useful, so I needed to specify a unique constraint/index. It looks like that will be supported in 3.9. > > But I overlooked that WHERE clause. Added another feature request for this: > https://github.com/jOOQ/jOOQ/issues/5637 > > But do you need it in your example? > I don't think I need to use the where clause. Though I imagine it would be a useful pattern. The two main Upsert + Jooq features I would love to see are: 1. batch operation working with upserts (which is partially supported by generating a list of custom insert statements) 2. the ability to specify the list of columns rather the .onKeyConflict which doesn't support all of my use cases. > > But I believe any valid Index or constrain can be applied (Postgres). >> Can we add a method that takes a .onConflict(Index_name or constraint_name) >> ? >> > > Yes, in jOOQ 3.9. > All these great features coming out in 3.9. Can't wait. > > >> I'm assuming jooq can auto-gen indexes as well? >> > > No, we don't generate indexes yet as that information hasn't been useful > to general jOOQ API usage (yet). > That's fine. I suppose there's not much usability added by having java objects generated for them. > > Best Regards, > Lukas > > -- > You received this message because you are subscribed to the Google Groups > "jOOQ User Group" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- Thank you Samir Faci https://keybase.io/csgeek -- You received this message because you are subscribed to the Google Groups "jOOQ User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
