spec/adapters/sqlite_spec.rb in sequel-4.45.0 vs spec/adapters/sqlite_spec.rb in sequel-4.46.0

- old
+ new

@@ -3,23 +3,27 @@ require File.join(File.dirname(File.expand_path(__FILE__)), 'spec_helper.rb') describe "An SQLite database" do before do @db = DB + deprecated do @fk = @db.foreign_keys + end end after do @db.drop_table?(:fk) - @db.auto_vacuum = :none - @db.run 'VACUUM' - @db.foreign_keys = @fk - @db.case_sensitive_like = true + deprecated do + @db.auto_vacuum = :none + @db.run 'VACUUM' + @db.foreign_keys = @fk + @db.case_sensitive_like = true + end @db.use_timestamp_timezones = false Sequel.datetime_class = Time end - it "should support getting setting pragma values" do + deprecated "should support getting setting pragma values" do @db.pragma_set(:auto_vacuum, '0') @db.run 'VACUUM' @db.pragma_get(:auto_vacuum).to_s.must_equal '0' @db.pragma_set(:auto_vacuum, '1') @db.run 'VACUUM' @@ -27,27 +31,27 @@ @db.pragma_set(:auto_vacuum, '2') @db.run 'VACUUM' @db.pragma_get(:auto_vacuum).to_s.must_equal '2' end - it "should support getting and setting the auto_vacuum pragma" do + deprecated "should support getting and setting the auto_vacuum pragma" do @db.auto_vacuum = :full @db.run 'VACUUM' @db.auto_vacuum.must_equal :full @db.auto_vacuum = :incremental @db.run 'VACUUM' @db.auto_vacuum.must_equal :incremental proc {@db.auto_vacuum = :invalid}.must_raise(Sequel::Error) end - it "should respect case sensitive like false" do + deprecated "should respect case sensitive like false" do @db.case_sensitive_like = false @db.get(Sequel.like('a', 'A')).to_s.must_equal '1' end - it "should respect case sensitive like true" do + deprecated "should respect case sensitive like true" do @db.case_sensitive_like = true @db.get(Sequel.like('a', 'A')).to_s.must_equal '0' end it "should support casting to Date by using the date function" do @@ -61,26 +65,26 @@ it "should provide the SQLite version as an integer" do @db.sqlite_version.must_be_kind_of(Integer) end - it "should support setting and getting the foreign_keys pragma" do + deprecated "should support setting and getting the foreign_keys pragma" do (@db.sqlite_version >= 30619 ? [true, false] : [nil]).must_include(@db.foreign_keys) @db.foreign_keys = true @db.foreign_keys = false end - it "should enforce foreign key integrity if foreign_keys pragma is set" do + deprecated "should enforce foreign key integrity if foreign_keys pragma is set" do @db.foreign_keys = true @db.create_table!(:fk){primary_key :id; foreign_key :parent_id, :fk} @db[:fk].insert(1, nil) @db[:fk].insert(2, 1) @db[:fk].insert(3, 3) proc{@db[:fk].insert(4, 5)}.must_raise(Sequel::ForeignKeyConstraintViolation, Sequel::ConstraintViolation, Sequel::DatabaseError) end if DB.sqlite_version >= 30619 - it "should not enforce foreign key integrity if foreign_keys pragma is unset" do + deprecated "should not enforce foreign key integrity if foreign_keys pragma is unset" do @db.foreign_keys = false @db.create_table!(:fk){primary_key :id; foreign_key :parent_id, :fk} @db[:fk].insert(1, 2) @db[:fk].all.must_equal [{:id=>1, :parent_id=>2}] end @@ -102,22 +106,22 @@ @db.tables.wont_include(:fk) @db.create_table!(:fk){String :name} @db.tables.must_include(:fk) end - it "should support getting and setting the synchronous pragma" do + deprecated "should support getting and setting the synchronous pragma" do @db.synchronous = :off @db.synchronous.must_equal :off @db.synchronous = :normal @db.synchronous.must_equal :normal @db.synchronous = :full @db.synchronous.must_equal :full proc {@db.synchronous = :invalid}.must_raise(Sequel::Error) end - it "should support getting and setting the temp_store pragma" do + deprecated "should support getting and setting the temp_store pragma" do @db.temp_store = :default @db.temp_store.must_equal :default @db.temp_store = :file @db.temp_store.must_equal :file @db.temp_store = :memory @@ -525,34 +529,32 @@ @db['PRAGMA table_info(?)', :test3][:id][:pk].to_i.must_equal 1 @db[:test3].select(:id).all.must_equal [{:id => 1}, {:id => 3}] end - if DB.foreign_keys - it "should keep foreign keys when dropping a column" do - @db.create_table! :test do - primary_key :id - String :name - Integer :value - end - @db.create_table! :test3 do - String :name - Integer :value - foreign_key :test_id, :test, :on_delete => :set_null, :on_update => :cascade - end + it "should keep foreign keys when dropping a column" do + @db.create_table! :test do + primary_key :id + String :name + Integer :value + end + @db.create_table! :test3 do + String :name + Integer :value + foreign_key :test_id, :test, :on_delete => :set_null, :on_update => :cascade + end - @db[:test3].insert(:name => "abc", :test_id => @db[:test].insert(:name => "foo", :value => 3)) - @db[:test3].insert(:name => "def", :test_id => @db[:test].insert(:name => "bar", :value => 4)) + @db[:test3].insert(:name => "abc", :test_id => @db[:test].insert(:name => "foo", :value => 3)) + @db[:test3].insert(:name => "def", :test_id => @db[:test].insert(:name => "bar", :value => 4)) - @db.drop_column :test3, :value + @db.drop_column :test3, :value - @db[:test].filter(:name => 'bar').delete - @db[:test3][:name => 'def'][:test_id].must_be_nil + @db[:test].filter(:name => 'bar').delete + @db[:test3][:name => 'def'][:test_id].must_be_nil - @db[:test].filter(:name => 'foo').update(:id=>100) - @db[:test3][:name => 'abc'][:test_id].must_equal 100 - end + @db[:test].filter(:name => 'foo').update(:id=>100) + @db[:test3][:name => 'abc'][:test_id].must_equal 100 end it "should support rename_column operations" do @db[:test2].delete @db.add_column :test2, :xyz, :text @@ -688,10 +690,10 @@ end @db.transaction(:mode => :deferred) do sqls.last.must_equal "BEGIN DEFERRED TRANSACTION" end @db.transaction do - sqls.last.must_equal Sequel::Database::SQL_BEGIN + sqls.last.must_equal 'BEGIN' end @db.transaction_mode.must_be_nil @db.transaction_mode = :immediate @db.transaction_mode.must_equal :immediate