sql

All things SQL and JDBC...
frankitox 2020-11-10T12:55:34.298400Z

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.

seancorfield 2020-11-10T15:58:27.299400Z

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! 😂

😂 1
dpsutton 2020-11-10T16:02:17.300200Z

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 Posobin 2020-11-10T19:13:24.302100Z

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?

seancorfield 2020-11-10T19:30:05.303400Z

(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)

seancorfield 2020-11-10T19:30:59.304200Z

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

seancorfield 2020-11-10T19:31:34.304700Z

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

Gleb Posobin 2020-11-10T19:33:17.305700Z

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

seancorfield 2020-11-10T19:54:24.307600Z

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.

seancorfield 2020-11-10T19:55:05.308500Z

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.

seancorfield 2020-11-10T19:55:20.308900Z

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

seancorfield 2020-11-10T19:56:38.310200Z

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.

👍 1