-
Notifications
You must be signed in to change notification settings - Fork 43
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
Transaction improvements #203
base: master
Are you sure you want to change the base?
Conversation
Nice! |
On this line: https://github.com/jreinert/crecto/blob/transaction_improvements/src/crecto/adapters/mysql_adapter.cr#L58 Does this work? if conn.is_a?(DB::TopLevelTransaction)
return execute(conn, "SELECT * FROM #{changeset.instance.class.table_name} WHERE (#{changeset.instance.class.primary_key_field} = #{last_insert_id})")
end |
well, |
To recap: This PR is on hold, because the specs for the query methods introduced to |
51b9dc2
to
c82b3c0
Compare
c82b3c0
to
b1512e8
Compare
29eaaaf
to
ad5a6ff
Compare
I now use compiler flags to determine which db the specs are run against and depending on those enable/disable some specs. Nested transactions aren't supported by sqlite so i exclude the spec for it when run against sqlite. The tx read spec (reading records created within a transaction from within the same transaction) should work for all databases but there are underlying issues in the mysql and sqlite drivers that prevent this. This is why i mark the tx read spec as pending for mysql and sqlite. |
What's a bit of a mystery to me is the currently failing spec for delete_all in a transaction for sqlite. I can't reproduce this on my local machine (arch linux with sqlite 3.30.1). Any help in figuring out what goes wrong there would be much appreciated! |
7f47b9c
to
3508411
Compare
probably a relic from when tx was a class variable in Repo
this disables the tx read specs for mysql and sqlite
3508411
to
7fd4945
Compare
Repo
instead oftx
insidetransaction!
blockLiveTransaction
I noticed the using
Repo.all
inside of atransaction!
block won't return any of the records created inside of the transaction which is why i included all read methods forLiveTransaction