Fork me on GitHub
#sql
<
2020-11-10
>
frankitox12:11:34

Great will do. Honestly this is one the best documentations I've ever read! It's very clear and goes straight to the point 👌, I'll keep it in mind when writing my own docs.

seancorfield15:11:27

Thank you. I do not consider myself to be a good writer of documentation -- at one of my previous jobs, after I left, they hired a technical writer specifically to rewrite all the in-house docs I'd written! 😂

😂 3
dpsutton16:11:17

an alternative way to look at it, a developer was able to maintain a trove of documentation that otherwise required a dedicated technical writer

Gleb Posobin19:11:24

I want to test a function that uses next.jdbc/with-transaction , so far I have been wrapping functions in tests with (next.jdbc/with-transaction [tx ds {:rollback-only true}]), but seems like the nested transaction commits changes to the db, even though the outer is rollback only. How do I work around this?

seancorfield19:11:05

(I haven't added that to the Transactions page of the docs yet because I'm not sure I want to encourage people to use it much)

seancorfield19:11:59

In your case, (binding [next.jdbc.transaction/*nested-tx* :ignore] ... your test ...) should do what you need.

seancorfield19:11:34

i.e., with the :rollback-only true tx inside that binding.

Gleb Posobin19:11:17

Thank you! But I guess that means that such code is not encouraged?

seancorfield19:11:24

Well... cloure.java.jdbc's default behavior was :ignore which is different. I haven't really had a chance to extensively test behavior around nested TX. So it's fine for you to use it in tests at this point I think.

seancorfield19:11:05

But be aware that if you bind it to :ignore for tests, you won't detect any cases where you nest TX accidentally in your non-test code.

seancorfield19:11:20

I just haven't really decided how best to write this up...

seancorfield19:11:38

I plan to add it to the c.j.j migration docs for sure, since it's a way to match c.j.j's behavior, but in general you can't nest TX -- and the behavior if you attempt it varies from DB to DB.

👍 3