Hello,
Today on polish rails community channel somone asked about extended
insert functionality in sequel, is it available. Well i must see i
don't see anything giving such functionality inside documentation but
i thnik it is pretty simple in implementation, we just need to
override for example << method od Datase? (or dataset for each
adapter)
This is example of uch functionality.
require 'rubygems'
require 'sequel'
DB = Sequel.sqlite # memory database
DB.create_table :items do # Create a new table
primary_key :id
column :name, :text
column :price, :float
end
items = DB[:items] # Create a dataset
items << [{:name => 'abc', :price => rand * 100}, {:name =>
'def', :price => rand * 100}, {:name => 'ghi', :price => rand * 100}]
This will produce sql:
"INSERT items (name, price) VALUES (('abc', 123), ('def', 123), ('ghi',
123))"
And i think is obvious for everybody that such sql query will be much
faster than regullary 3 single queries for every row.
I seems that << only refers to insert_sql so we don't need to care
about any callbacks or typecast of defined schema ?
I'm wondering what do you thnik about that Jeremy ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/sequel-talk?hl=en
-~----------~----~----~----~------~----~------~--~---