Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions lib/arjdbc/abstract/database_statements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,15 @@ module DatabaseStatements

NO_BINDS = [].freeze

unless ::ActiveRecord::ConnectionAdapters::AbstractAdapter.method_defined?(:mark_transaction_written_if_write)
def mark_transaction_written_if_write(sql)
if write_query?(sql)
ensure_writes_are_allowed(sql)
mark_transaction_written
end
def mark_transaction_written_if_write(sql)
if write_query?(sql)
ensure_writes_are_allowed(sql)
mark_transaction_written
end
end

unless ::ActiveRecord::ConnectionAdapters::AbstractAdapter.method_defined?(:check_if_write_query)
def check_if_write_query(sql)
ensure_writes_are_allowed(sql) if write_query?(sql)
end
def check_if_write_query(sql)
ensure_writes_are_allowed(sql) if write_query?(sql)
end

def exec_insert(sql, name = nil, binds = NO_BINDS, pk = nil, sequence_name = nil, returning: nil)
Expand Down
7 changes: 2 additions & 5 deletions lib/arjdbc/sqlite3/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ module SQLite3
"cache_size" => 2000
}

COLUMN_TAKES_CAST_TYPE = ConnectionAdapters::Column.instance_method(:initialize).
parameters.any? { |_kind, name| name == :cast_type }

class StatementPool < ConnectionAdapters::StatementPool # :nodoc:
private
def dealloc(stmt)
Expand Down Expand Up @@ -475,7 +472,7 @@ def new_column_from_field(table_name, field, definitions)
rowid = is_column_the_rowid?(field, definitions)

column_args = [field["name"]]
column_args << lookup_cast_type(field["type"]) if COLUMN_TAKES_CAST_TYPE
column_args << lookup_cast_type(field["type"])
column_args.push(
default_value,
type_metadata,
Expand Down Expand Up @@ -617,7 +614,7 @@ def copy_table(from, to, options = {})
column_options[:stored] = column.virtual_stored?
column_options[:type] = column.type
elsif column.has_default?
type = column.respond_to?(:fetch_cast_type) ? column.fetch_cast_type(self) : lookup_cast_type_from_column(column)
type = column.fetch_cast_type(self)
default = type.deserialize(column.default)
default = -> { column.default_function } if default.nil?

Expand Down
Loading