fulcrologic / fulcro-rad-sql

SQL Plugin for Fulcro RAD
MIT License
4 stars 12 forks source link

Create wrap-transaction save middleware #6

Open awkay opened 4 years ago

awkay commented 4 years ago
(->
  ...
  (your/save-middleware)
  (sql/wrap-transaction))

would allow multiple SQL databases to safely work together, and if possible would defer FK checks until the end of the transaction (not sure that is std SQL).

Remember that the env contains connection-pools, which is a map from db name to db. Should be able to use with-transaction and replace all of those in that map in env to pass on to next handler.

davewo commented 4 years ago

Turns out that marking constraints as DEFERRABLE is standard SQL, and Postgresql supports it. MySQL does not support DEFERRABLE however.

awkay commented 4 years ago

Surprising. Not sure how some transactions could even work that way...you'd have to loosen your desired constraints in any case where you needed to create a "loop" of data.

davewo commented 4 years ago

set foreign_key_checks=0; looks like what one would need to do in mysql