-
-
Replying to @mountain_ghosts
I think it works fine on rails 5 and 6 if you have the appropriate unique indexes and postgres?
1 reply 0 retweets 2 likes -
Replying to @penelope_zone @samphippen
really? what does it actually do in SQL now?
1 reply 0 retweets 0 likes -
Replying to @mountain_ghosts @samphippen
my prior experience: - find_or_create does not work - rescuing RecordNotUnique - can deadlock mysql - behaves differently across mysql and postgres transaction semantics so you still need db-specific code e.g. savepoints
1 reply 0 retweets 2 likes -
Replying to @mountain_ghosts @samphippen
I know they added some alternate form of this, which is just broken in a different way (INSERT and then SELECT on failure), and an actual upsert API
1 reply 0 retweets 0 likes -
Replying to @mountain_ghosts
Hey
@sgrif I'm sure you know about these things, would you care to weigh in?2 replies 0 retweets 0 likes -
`find_or_create` is impossible to actually do atomically without *some* sort of trade-off. You can do something extremely janky involving doing an insert in a CTE and then doing a select with a union to the CTE. `create_or_find_by` is probably the best you can do on MySQL
1 reply 0 retweets 1 like
Important to note that CTEs *do not* make the query atomic. It just reduces the potential for race conditions by removing round trip time. There is *no* atomic solution for this on any DB
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.