C
Chuck Remes
I really like the simplicity of Sequel [1], but right now it is
giving me fits. After I insert a row into the database, I can't seem
to get it to persist any updates that I make to that row. Here's an
example.
[cremes@calvin tmp]$ sqlite3 test.db
SQLite version 3.5.1
Enter ".help" for instructions
sqlite> create table test_table (a text, b text, c text);
sqlite> .tables
test_table
[cremes@calvin tmp]$ sequel 'sqlite:///test.db'
Your database is stored in DB...
irb(main):001:0> d = DB[:test_table]
=> #<Sequel::SQLite:
ataset:0x2aaaab5486e0 @columns=nil, @opts=
{:from=>[:test_table]}, @row_proc=nil, @db=#<Sequel::SQLite:
atabase:
0x2af90882ab50 @pool=#<Sequel::ConnectionPool:0x2af90882aad8
@available_connections=[#<SQLite3:
atabase:0x2af90882a880
@type_translation=true, @driver=#<SQLite3:
river::Native:
river:
0x2af9088136d0 @authorizer={}, @callback_data={}, @trace={},
@busy_handler={}>, @statement_factory=SQLite3::Statement,
@results_as_hash=false,
@handle=#<SWIG::TYPE_p_sqlite3:0x2af908813590>,
@transaction_active=false, @closed=false, @translator=nil>],
@connection_proc=#<Proc:0x00002af9073d8198@/usr/lib/ruby/gems/1.8/
gems/sequel-0.3.0.1/lib/sequel/database.rb:27>, @created_count=1,
@mutex=#<Mutex:0x2af90882aa88>, @allocated={}, @max_size=4>, @opts=
{
assword=>nil, :host=>nil,
ort=>nil, :database=>"test.db", :user=>ni
l}, @logger=nil, @single_threaded=false>>
irb(main):002:0> d.all.count
NoMethodError: undefined method `count' for []:Array
from (irb):2
irb(main):003:0> d.all
=> []
irb(main):004:0> d << {:a => 'sample1', :b => 'sample2'}
=> 1
irb(main):005:0> d.all
=> [{:b=>"sample2", :a=>"sample1", :c=>nil}]
irb(main):006:0> d.filter('a = ?', 'sample1').order
b).last.update
c => 'sample3')
=> {:b=>"sample2", :a=>"sample1", :c=>"sample3"}
irb(main):007:0> d.all
=> [{:b=>"sample2", :a=>"sample1", :c=>nil}]
irb(main):008:0>
Notice how 'sample3' goes missing after the +update+ method executes.
The result from that call clearly shows a hash with that field
updated, but when I ask the database to print that row it doesn't
show up. I tried executing a +save+ but that method isn't defined on
Array.
Can anyone help me out?
cr
giving me fits. After I insert a row into the database, I can't seem
to get it to persist any updates that I make to that row. Here's an
example.
[cremes@calvin tmp]$ sqlite3 test.db
SQLite version 3.5.1
Enter ".help" for instructions
sqlite> create table test_table (a text, b text, c text);
sqlite> .tables
test_table
[cremes@calvin tmp]$ sequel 'sqlite:///test.db'
Your database is stored in DB...
irb(main):001:0> d = DB[:test_table]
=> #<Sequel::SQLite:
{:from=>[:test_table]}, @row_proc=nil, @db=#<Sequel::SQLite:
0x2af90882ab50 @pool=#<Sequel::ConnectionPool:0x2af90882aad8
@available_connections=[#<SQLite3:
@type_translation=true, @driver=#<SQLite3:
0x2af9088136d0 @authorizer={}, @callback_data={}, @trace={},
@busy_handler={}>, @statement_factory=SQLite3::Statement,
@results_as_hash=false,
@handle=#<SWIG::TYPE_p_sqlite3:0x2af908813590>,
@transaction_active=false, @closed=false, @translator=nil>],
@connection_proc=#<Proc:0x00002af9073d8198@/usr/lib/ruby/gems/1.8/
gems/sequel-0.3.0.1/lib/sequel/database.rb:27>, @created_count=1,
@mutex=#<Mutex:0x2af90882aa88>, @allocated={}, @max_size=4>, @opts=
{
l}, @logger=nil, @single_threaded=false>>
irb(main):002:0> d.all.count
NoMethodError: undefined method `count' for []:Array
from (irb):2
irb(main):003:0> d.all
=> []
irb(main):004:0> d << {:a => 'sample1', :b => 'sample2'}
=> 1
irb(main):005:0> d.all
=> [{:b=>"sample2", :a=>"sample1", :c=>nil}]
irb(main):006:0> d.filter('a = ?', 'sample1').order
=> {:b=>"sample2", :a=>"sample1", :c=>"sample3"}
irb(main):007:0> d.all
=> [{:b=>"sample2", :a=>"sample1", :c=>nil}]
irb(main):008:0>
Notice how 'sample3' goes missing after the +update+ method executes.
The result from that call clearly shows a hash with that field
updated, but when I ask the database to print that row it doesn't
show up. I tried executing a +save+ but that method isn't defined on
Array.
Can anyone help me out?
cr