On 24/06/11 1:08 AM, jnicklas wrote:
I am upgrading a legacy application from DataMapper 0.10.2 to 1.1.0.
The app uses transactions in its tests, and I can't really figure out
how transactions are supposed to work in DataMapper.

What I'm doing basically boils down to this:

   repo = DataMapper.repository(:default)
   transaction = DataMapper::Transaction.new(repo)
   transaction.begin
     Customer.create(:name =>  'Jonas')
   transaction.rollback
Not sure whether that should work or not, but the following works for me on 1.1:

    repository(:default) do |repository|
    transaction = DataMapper::Transaction.new(repository)
    transaction.begin
    repository(:default).adapter.push_transaction(transaction)
    # work
    transaction = repository(:default).adapter.pop_transaction
    transaction.rollback

Maybe also add logging to your example to see what is/isn't being executed?

Xaveir


This pastie contains a full example which illustrates the problem:
http://pastie.org/2111523

I am getting this output:

   ### DM TRANSACTION ###
   before: 0
   during: 1
   after: 1
   ### MANUAL TRANSACTION ###
   before: 0
   during: 1
   after: 0

As you can see, the manual transaction is rolled back properly, while
the DM transaction is in fact not rolled back at all.

Am I doing something wrong, or is this just broken?

/Jonas


--
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to