
#transaction method not added to DataMapper::Resource
Reported by LeMarsu | April 3rd, 2010 @ 10:52 AM | in 1.0.0
When defining resources before calling DataMapper.setup(...), the method #transaction (at least) is not created on the resource.
require 'extlib'
require 'dm-core'
require 'dm-transactions'
class Resource1
include DataMapper::Resource
property :id, Serial
end
DataMapper.setup(:default, 'sqlite3:memory:')
class Resource2
include DataMapper::Resource
property :id, Serial
end
p Resource1.new.methods.grep /transaction/ # => []
p Resource2.new.methods.grep /transaction/ # => ["transaction"]
tested on:
- gem (dm-core v0.10.2)
- master dm-core (c03f8da874a6ff8bd3ca435c74743fd2b5f012e6) with master dm-transactions (7e77fc48f3532f402894945d3cd0f0c29a4f6bb7).
Comments and changes to this ticket
-
Martin Gamsjaeger (snusnu) April 3rd, 2010 @ 11:24 AM
- State changed from new to confirmed
- Assigned user set to Martin Gamsjaeger (snusnu)
- Milestone set to 1.0.0
This will be fixed in dm-transactions. As soon as dm-transactions is required, the transaction methods should be available on Repository,Model and Resource. It is safe to do so, because once someone explicitly required dm-transactions, we can rely on the fact an adapter with transaction support will be used eventually.
-
Martin Gamsjaeger (snusnu) April 11th, 2010 @ 10:38 AM
- State changed from confirmed to accepted
-
sundbp April 19th, 2010 @ 06:28 AM
There's similar issues with adapters not getting transaction support when using rails3 and dm-rails. I've tracked it down to being because of the const_added hook depends on dm-transactions being required before any adapter, which is not the case (at least for me) when using Bundler.require.
It can be worked around by manually requiring dm-transactions before running Bundler.require in application.rb.
wycats discuss this sort of problem here: http://yehudakatz.com/2010/04/17/ruby-require-order-problems/
He's in favor of not relying on require order in general fwiw.
-
Dan Kubb (dkubb) April 30th, 2010 @ 07:40 PM
- State changed from accepted to resolved
(from [eaca32fcbdf2e2c09f3d8982d0afd44d0b1dcbf4]) Makes #transaction method available on require 'dm-transactions'
If dm-transactions is required explicitly, assume
that an adapter with builtin transaction support
will be used eventually.[#1232 state:resolved] http://github.com/datamapper/dm-transactions/commit/eaca32fcbdf2e2c...
-
Martin Gamsjaeger (snusnu) May 2nd, 2010 @ 08:01 PM
Patrik,
You might want to try dm-transactions master, specifically everything after
http://github.com/datamapper/dm-transactions/commit/66a9537d19f9c71...
I hope I fixed the remaining require order dependencies. Can you confirm that?
-
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
People watching this ticket
Referenced by
-
1232 #transaction method not added to DataMapper::Resource [#1232 state:resolved] http://github.com/datamapper/dm-t...