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. 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? 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. > 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). 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.
