Skip to content
Browse files

Add transaction check to SQLite2 adapter to fix test_sqlite_add_colum…

…n_in_transaction_raises_statement_invalid [#1669 state:resolved]

Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
  • Loading branch information...
1 parent ab7c25d commit abfa46e3a6ba0e91f377a073d208f31f99a7a008 @ffmike ffmike committed with wycats
Showing with 4 additions and 0 deletions.
  1. +4 −0 activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
View
4 activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
@@ -402,6 +402,10 @@ def rename_table(name, new_name)
end
def add_column(table_name, column_name, type, options = {}) #:nodoc:
+ if @connection.respond_to?(:transaction_active?) && @connection.transaction_active?
+ raise StatementInvalid, 'Cannot add columns to a SQLite database while inside a transaction'
+ end
+
alter_table(table_name) do |definition|
definition.column(column_name, type, options)
end

0 comments on commit abfa46e

Please sign in to comment.
Something went wrong with that request. Please try again.