Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create wrap-transaction save middleware #6

Open
awkay opened this issue Mar 25, 2020 · 3 comments
Open

Create wrap-transaction save middleware #6

awkay opened this issue Mar 25, 2020 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@awkay
Copy link
Member

awkay commented Mar 25, 2020

(->
  ...
  (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
Copy link
Collaborator

davewo commented Mar 29, 2020

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

@awkay
Copy link
Member Author

awkay commented Mar 30, 2020

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
Copy link
Collaborator

davewo commented Mar 30, 2020

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

@awkay awkay unassigned davewo Jan 1, 2021
@awkay awkay added the help wanted Extra attention is needed label Jan 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants