korma / Korma

Tasty SQL for Clojure.
http://sqlkorma.com
1.47k stars 222 forks source link

Fixes issue with thread-safety on with-db #236

Closed ceterumnet closed 10 years ago

ceterumnet commented 10 years ago

I've added 2 tests to the integration test with-db

The tests:

  1. verify that the version of the with-db I wrote to fix lazyness broke thread safety on the with-db macro.
  2. verify that my new version fixes the thread safety issue.

Let me know what you think of this.

ceterumnet commented 10 years ago

Argh - this isn't quite right. I need to tweak the delay factors on the threads...I'll update this shortly.

ceterumnet commented 10 years ago

Ok - this request should be good to go.

immoh commented 10 years ago

Sorry for the delay. I think it fixes the bug but I wrote some improvement suggestions about the code.

ceterumnet commented 10 years ago

Ok - I've pushed the changes. However, I wasn't able to eliminate the dynamic var from the lazy relationships. It seems that those are evaluated in a way that the post queries are generated so that they escape the binding. Almost like they are generated before the do-query...

Let me know if you have any additional concerns.

immoh commented 10 years ago

You're right, post queris are generated before do-query and that's why the binding is not available. Too bad, it wouldn't have simplified it a bit and probably fixed other bugs related to connection escaping.

One more concern: I don't see why transaction should be changed, do you have some example in mind why it wouldn't work? If so, we should probably add a failing test that this change fixes.

ceterumnet commented 10 years ago

I can't remember why I changed it ... I've rolled that back and pushed.

Cheers, Dave

immoh commented 10 years ago

This is good to go. Thanks.

mayankag commented 10 years ago

@immoh can you please release 0.3.2 with this change included. I need to use the with-db feature, and would like to use the thread-safe version.

thank you so much!

immoh commented 10 years ago

0.3.2 released

mayankag commented 10 years ago

thank you!