Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Move exec insert #294

Closed
wants to merge 2 commits into from

1 participant

@metaskills

Aaron, just following up on moving this method to abstract adapter. Since as a 3rd party adapter developer, this was 100% of my failures when I first started work.

@metaskills metaskills closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 22, 2011
  1. @metaskills

    The #substitute_at gets an ActiveRecord::ConnectionAdapters::Column i…

    metaskills authored
    …n #insert to match replacement in #exec_query.
  2. @metaskills
This page is out of date. Refresh to see the latest.
View
7 activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
@@ -55,6 +55,13 @@ def execute(sql, name = nil)
def exec_query(sql, name = 'SQL', binds = [])
end
+ # Executes insert +sql+ statement in the context of this connection using
+ # +binds+ as the bind substitutes. +name+ is the logged along with
+ # the executed +sql+ statement.
+ def exec_insert(sql, name, binds)
+ exec_query(sql, name, binds)
+ end
+
# Returns the last auto-generated ID from the affected table.
#
# +id_value+ will be returned unless the value is nil, in
View
4 activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -427,10 +427,6 @@ def exec_query(sql, name = 'SQL', binds = [])
end
end
- def exec_insert(sql, name, binds)
- exec_query(sql, name, binds)
- end
-
def last_inserted_id(result)
@connection.insert_id
end
View
4 activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -552,10 +552,6 @@ def exec_query(sql, name = 'SQL', binds = [])
end
end
- def exec_insert(sql, name, binds)
- exec_query(sql, name, binds)
- end
-
def sql_for_insert(sql, pk, id_value, sequence_name, binds)
unless pk
_, table = extract_schema_and_table(sql.split(" ", 4)[2])
View
4 activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb
@@ -173,10 +173,6 @@ def exec_query(sql, name = nil, binds = [])
end
end
- def exec_insert(sql, name, binds)
- exec_query(sql, name, binds)
- end
-
def last_inserted_id(result)
@connection.last_insert_row_id
end
View
2  activerecord/lib/active_record/relation.rb
@@ -56,7 +56,7 @@ def insert(values)
end
substitutes.each_with_index do |tuple, i|
- tuple[1] = conn.substitute_at(tuple.first, i)
+ tuple[1] = conn.substitute_at(binds[i][0], i)
end
if values.empty? # empty insert
Something went wrong with that request. Please try again.