Skip to content

Commit

Permalink
Minor spec fixes to keep specs passing on SQLite 3.37.0+
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyevans committed Apr 12, 2022
1 parent 086138c commit 771c1d1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 3 additions & 1 deletion spec/adapters/sqlite_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,9 @@
@db[:fk].insert(:a=>100, :b=>10)
@db[:fk].select_order_map([:a, :b, :c, :d, :e]).must_equal [[100, 10, 211, 212, 213]]

@db.schema(:fk).map{|_,v| v[:generated]}.must_equal [false, false, true, true, true]
# Generated columns do not show up in schema on SQLite 3.37.0 (or maybe 3.38.0)
expected = DB.sqlite_version >= 33700 ? [false, false] : [false, false, true, true, true]
@db.schema(:fk).map{|_,v| v[:generated]}.must_equal expected
end if DB.sqlite_version >= 33100
end

Expand Down
8 changes: 5 additions & 3 deletions spec/bin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def bin(opts={})
File.read(OUTPUT)
end

int_type = DB.sqlite_version >= 33700 ? "INTEGER" : 'integer'

after do
DB.disconnect
DB2.disconnect
Expand Down Expand Up @@ -91,8 +93,8 @@ def bin(opts={})
DB2.tables.sort_by{|t| t.to_s}.must_equal [:a, :b]
DB[:a].all.must_equal [{:a=>1, :name=>'foo'}]
DB[:b].all.must_equal [{:a=>1}]
DB2.schema(:a).map{|col, sch| [col, *sch.values_at(:allow_null, :default, :primary_key, :db_type, :type, :ruby_default)]}.must_equal [[:a, false, nil, true, "integer", :integer, nil], [:name, true, nil, false, "varchar(255)", :string, nil]]
DB2.schema(:b).map{|col, sch| [col, *sch.values_at(:allow_null, :default, :primary_key, :db_type, :type, :ruby_default)]}.must_equal [[:a, true, nil, false, "integer", :integer, nil]]
DB2.schema(:a).map{|col, sch| [col, *sch.values_at(:allow_null, :default, :primary_key, :db_type, :type, :ruby_default)]}.must_equal [[:a, false, nil, true, int_type, :integer, nil], [:name, true, nil, false, "varchar(255)", :string, nil]]
DB2.schema(:b).map{|col, sch| [col, *sch.values_at(:allow_null, :default, :primary_key, :db_type, :type, :ruby_default)]}.must_equal [[:a, true, nil, false, int_type, :integer, nil]]
DB2.indexes(:a).must_equal({})
DB2.indexes(:b).must_equal(:b_a_index=>{:unique=>false, :columns=>[:a]})
DB2.foreign_key_list(:a).must_equal []
Expand Down Expand Up @@ -195,7 +197,7 @@ def bin(opts={})
column, schema = h.values.first.first
column.must_equal :a
schema.delete(:generated) # May be present on SQLite 3.31+
schema.must_equal(:type=>:integer, :db_type=>"integer", :ruby_default=>nil, :allow_null=>true, :default=>nil, :primary_key=>false)
schema.must_equal(:type=>:integer, :db_type=>int_type, :ruby_default=>nil, :allow_null=>true, :default=>nil, :primary_key=>false)
end

it "-X should dump the index cache" do
Expand Down

0 comments on commit 771c1d1

Please sign in to comment.