Displaying 13 results from an estimated 13 matches for "begin_db_transaction".
2006 Aug 10
6
save without commit ?
How do I get ''save'' to execute without commit?
I have tried:
ActiveRecord::Base.connection.begin_db_transaction
# do some stuff that doesn''t issue a database COMMIT statement
# then:
@myObject.save
# this issues a COMMIT but it shouldn''t! Shouldn''t it wait until I''ve
called:
ActiveRecord::Base.connection.commit_db_transaction
?
what am I doing wrong?
thanks for any...
2006 Apr 25
2
Transactions and migrations (lots of records)???
...;'t really help me.
What I want to do is start a transaction before I start looping then watch
a counter and every 50th time, commit, then open another one. Then have a
final commit.
I''ll deal with errors elsewhere... right now I just need it to go faster.
I have a feeling I want begin_db_transaction and commit_db_transaction,
but I can''t figure out how to use them in the way I want.
Help! :-)
-philip
2006 Jun 15
4
testing with transactions
...ll up as a plugin perhaps).
Something in the way of:
# Wrap a block in a transaction. Returns result of block.
def transaction(start_db_transaction = true)
transaction_open = false
savepoint_open = false
savepoint_name = nil
begin
if block_given?
if start_db_transaction
begin_db_transaction
transaction_open = true
else
savepoint_name = create_savepoint
savepoint_open = true
end
yield
end
rescue Exception => database_transaction_rollback
if transaction_open
transaction_open = false
rollback_db_transaction
end
if...
2007 Nov 15
2
Story adapter and SQLite Was:What command to run all stories?
Hi, by switching to MySQL from SQLite, it fixed the problem. I ran
rdebug on it and it is trying to call
I ActiveRecord::Base.connection.begin_db_transaction. from
ActiveRecordSafetyListener.scenario_started. I don''t think SQLLite
likes transactions.
Ed
On Nov 15, 2007 10:56 AM, Ed Howland <ed.howland at gmail.com> wrote:
> If I run the story stand-alone, I get:
> ruby stories/additions/addition.rb
> Running 2 scenarios:
>
&...
2007 Feb 28
12
Specifying that code is called in a block
Not sure if this is possible currently.
I have a section of code like this:
ActiveRecord::Base.transaction do
cow.save!
duck.save!
dog.save!
end
(Names changed to protect the innocent.)
I''d like to specify that the saves run in a transaction. I can do
ActiveRecord::Base.should_receive(:transaction).and_yield
But is there any way to specify that the code is
2006 Apr 03
4
How to fake composite primary keys?
I know ActiveRecord doesn''t support composite primary keys, but I need to use
one, and I need it ASAP. I don''t need any composite foreign keys, luckily;
what I have is a table that stores old versions of rows in another table, so
the composite key is an id + date stamp. Would someone tell me a hack I can
use to support this?
--
View this message in context:
2006 Oct 16
3
Strange ActiveRecord error popping up
Hello guys, I''m developing a new app in Rails, and every now and then
I get an ActiveRecord error, I cannot reproduce exactly what triggers
it, hope you can help me, or give me tips on debugging this kind of
stuff. This time I got the error reporting page, but normally I would
just see the 500.html page, with no info about what went wrong.
This is the error (it''s the complete
2006 Feb 23
2
ActiveRecords question
I need to turn off and on the autocommit in MySql is there a method in
active records that allows me to do this?
or
is there a method which allows me to type in the pure mysql code
"set autocommit=0"
Thanks.
--
Posted via http://www.ruby-forum.com/.
2006 Jan 31
0
"cannot start a transaction within a transaction" sqlite error on OS X Tiger but not Windows
...`execute''
/usr/local/lib/ruby/site_ruby/1.8/sqlite/database.rb:194:in `execute''
/usr/local/lib/ruby/site_ruby/1.8/sqlite/database.rb:571:in `transaction''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/sqlite_adapter.rb:171:in
`begin_db_transaction''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/connection_adapters/abstract/database_statements.rb:48:in
`transaction''
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/transactions.rb:91:in
`transaction''
/usr/local/lib/ruby...
2005 Jul 28
0
autocommit problem with mysql
I''m trying to call save in active record after calling
begin_db_transaction. In the code I see no place where it calls
commit between create_or_update and the end of save.
However in the log I see a commit happen...and I don''t want commit to be called
does anyone know how to turn this off?
thanks
brian
2008 Mar 14
0
Adding before / after blocks to every spec
...itially) database transaction - to
give functionality similar to rails transactional fixtures.
Here is the module:
module Merb
module Test
module TransactionalSpecs
def begin_transaction
ActiveRecord::Base.send :increment_open_transactions
ActiveRecord::Base.connection.begin_db_transaction
end
def rollback_transaction
if Thread.current[''open_transactions''] != 0
ActiveRecord::Base.connection.rollback_db_transaction
Thread.current[''open_transactions''] = 0
end
end
def self.included(base)...
2006 Jun 01
4
how can I control when to commit a transaction?
hello
it seems like this question has appeared a few times with no answer:
how do you get rails to issue ''write'' statements (ie ''CREATE/UPDATE'') to
the database without committing each time?
I tried setting
ActiveRecord::Base.connection.begin_db_transaction
before calling any action on my object, but as soon as
myObject.save
or
myObject.update
is called, rails will issue a ''commit'' after the ''CREATE'' or ''UPDATE''.
The example given in the rails doc does not work for my application
because I can...
2012 Apr 27
3
rails console --sandbox is only half-baked
...u8J
<https://groups.google.com/forum/?fromgroups#%21msg/sequel-talk/VjfJcTD6s3w/Lbrc2RqVuu8J>
Here is how sandbox is handled by ActiveRecord:
activerecord/lib/active_record/railties/console_sandbox.rb:
ActiveRecord::Base.connection.increment_open_transactions
ActiveRecord::Base.connection.begin_db_transaction
at_exit do
ActiveRecord::Base.connection.rollback_db_transaction
ActiveRecord::Base.connection.decrement_open_transactions
end
This only handles the default database as noticed by Jeremy. If you have
models relying on different databases, only the default one will be
sandboxed.
Additio...