Skip to content

Instantly share code, notes, and snippets.

@methodmissing
Created October 2, 2008 02:17
Show Gist options
  • Select an option

  • Save methodmissing/14257 to your computer and use it in GitHub Desktop.

Select an option

Save methodmissing/14257 to your computer and use it in GitHub Desktop.
#abstract/database_statements.rb
# Returns the last auto-generated ID from the affected table.
def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
execute(sql, name)
id_value
end
#mysql_adapter.rb
def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) #:nodoc:
super sql, name
id_value || @connection.insert_id
end
#mysql_adapter.rb, perhaps less GC
def insert_sql(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil) #:nodoc:
@connection.query_with_result = false
super sql, name
id_value || @connection.insert_id
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment