sequel 4.5.0 → 4.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +14 -0
- data/README.rdoc +0 -1
- data/doc/mssql_stored_procedures.rdoc +43 -0
- data/doc/release_notes/3.18.0.txt +2 -3
- data/doc/release_notes/3.9.0.txt +1 -1
- data/doc/release_notes/4.6.0.txt +30 -0
- data/doc/security.rdoc +7 -0
- data/lib/sequel/adapters/jdbc/h2.rb +4 -4
- data/lib/sequel/adapters/jdbc/postgresql.rb +4 -0
- data/lib/sequel/adapters/oracle.rb +1 -0
- data/lib/sequel/adapters/shared/mssql.rb +94 -1
- data/lib/sequel/adapters/shared/mysql.rb +4 -4
- data/lib/sequel/adapters/shared/postgres.rb +4 -4
- data/lib/sequel/adapters/tinytds.rb +22 -4
- data/lib/sequel/adapters/utils/emulate_offset_with_row_number.rb +8 -2
- data/lib/sequel/database/dataset_defaults.rb +1 -1
- data/lib/sequel/model/associations.rb +1 -1
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/mssql_spec.rb +35 -0
- data/spec/adapters/oracle_spec.rb +4 -4
- data/spec/adapters/postgres_spec.rb +93 -93
- data/spec/adapters/spec_helper.rb +3 -1
- data/spec/bin_spec.rb +2 -0
- data/spec/core/database_spec.rb +22 -22
- data/spec/core/dataset_spec.rb +8 -8
- data/spec/core/expression_filters_spec.rb +1 -1
- data/spec/core/mock_adapter_spec.rb +2 -2
- data/spec/core/schema_generator_spec.rb +3 -3
- data/spec/core/spec_helper.rb +3 -1
- data/spec/core_extensions_spec.rb +3 -1
- data/spec/extensions/auto_validations_spec.rb +17 -17
- data/spec/extensions/caching_spec.rb +4 -4
- data/spec/extensions/error_splitter_spec.rb +1 -1
- data/spec/extensions/hook_class_methods_spec.rb +6 -6
- data/spec/extensions/migration_spec.rb +53 -53
- data/spec/extensions/pagination_spec.rb +9 -9
- data/spec/extensions/pg_array_associations_spec.rb +2 -2
- data/spec/extensions/pg_array_spec.rb +2 -2
- data/spec/extensions/pg_hstore_spec.rb +15 -15
- data/spec/extensions/pg_interval_spec.rb +3 -3
- data/spec/extensions/pg_range_spec.rb +20 -20
- data/spec/extensions/pg_row_spec.rb +1 -1
- data/spec/extensions/schema_caching_spec.rb +3 -3
- data/spec/extensions/spec_helper.rb +3 -1
- data/spec/extensions/static_cache_spec.rb +16 -16
- data/spec/extensions/tree_spec.rb +8 -8
- data/spec/extensions/validation_class_methods_spec.rb +10 -10
- data/spec/integration/database_test.rb +3 -3
- data/spec/integration/dataset_test.rb +6 -0
- data/spec/integration/migrator_test.rb +67 -67
- data/spec/integration/model_test.rb +2 -2
- data/spec/integration/schema_test.rb +1 -1
- data/spec/integration/spec_helper.rb +3 -1
- data/spec/integration/transaction_test.rb +2 -2
- data/spec/model/association_reflection_spec.rb +4 -4
- data/spec/model/associations_spec.rb +1 -1
- data/spec/model/class_dataset_methods_spec.rb +1 -1
- data/spec/model/eager_loading_spec.rb +7 -0
- data/spec/model/model_spec.rb +4 -4
- data/spec/model/record_spec.rb +20 -20
- data/spec/model/spec_helper.rb +2 -1
- data/spec/model/validations_spec.rb +1 -1
- data/spec/rspec_helper.rb +18 -0
- metadata +8 -3
@@ -31,7 +31,7 @@ module Sequel
|
|
31
31
|
# Change the default identifier output method to use for all databases,
|
32
32
|
def self.identifier_output_method=(v)
|
33
33
|
@identifier_output_method = v.nil? ? false : v
|
34
|
-
|
34
|
+
end
|
35
35
|
|
36
36
|
# The class to use for creating datasets. Should respond to
|
37
37
|
# new with the Database argument as the first argument, and
|
@@ -2229,7 +2229,7 @@ module Sequel
|
|
2229
2229
|
# and/or load other associations if #eager was used.
|
2230
2230
|
def post_load(all_records)
|
2231
2231
|
eager_graph_build_associations(all_records) if @opts[:eager_graph]
|
2232
|
-
eager_load(all_records) if @opts[:eager]
|
2232
|
+
eager_load(all_records) if @opts[:eager] && (row_proc || @opts[:eager_graph])
|
2233
2233
|
super
|
2234
2234
|
end
|
2235
2235
|
end
|
data/lib/sequel/version.rb
CHANGED
@@ -3,7 +3,7 @@ module Sequel
|
|
3
3
|
MAJOR = 4
|
4
4
|
# The minor version of Sequel. Bumped for every non-patch level
|
5
5
|
# release, generally around once a month.
|
6
|
-
MINOR =
|
6
|
+
MINOR = 6
|
7
7
|
# The tiny version of Sequel. Usually 0, only bumped for bugfix
|
8
8
|
# releases that fix regressions from previous versions.
|
9
9
|
TINY = 0
|
data/spec/adapters/mssql_spec.rb
CHANGED
@@ -643,3 +643,38 @@ describe "MSSQL optimistic locking plugin" do
|
|
643
643
|
proc{o2.save}.should raise_error(Sequel::NoExistingObject)
|
644
644
|
end
|
645
645
|
end unless DB.adapter_scheme == :odbc
|
646
|
+
|
647
|
+
describe "MSSQL Stored Procedure support" do
|
648
|
+
before do
|
649
|
+
@db = DB
|
650
|
+
@now = DateTime.now.to_s
|
651
|
+
@db.execute('CREATE PROCEDURE dbo.SequelTest
|
652
|
+
(@Input varchar(25), @IntegerInput int, @Output varchar(25) OUTPUT, @IntegerOutput int OUTPUT) AS
|
653
|
+
BEGIN SET @Output = @Input SET @IntegerOutput = @IntegerInput RETURN @IntegerInput END')
|
654
|
+
end
|
655
|
+
after do
|
656
|
+
@db.execute('DROP PROCEDURE dbo.SequelTest')
|
657
|
+
end
|
658
|
+
|
659
|
+
it "should return a hash of output variables" do
|
660
|
+
r = @db.call_mssql_sproc(:SequelTest, {:args => [@now, 1, :output, :output]})
|
661
|
+
r.should be_a_kind_of(Hash)
|
662
|
+
r.values_at(:var2, :var3).should == [@now, '1']
|
663
|
+
end
|
664
|
+
|
665
|
+
it "should support typed output variables" do
|
666
|
+
@db.call_mssql_sproc(:SequelTest, {:args => [@now, 1, :output, [:output, 'int']]})[:var3].should == 1
|
667
|
+
end
|
668
|
+
|
669
|
+
it "should support named output variables" do
|
670
|
+
@db.call_mssql_sproc(:SequelTest, {:args => [@now, 1, [:output, nil, 'output'], :output]})[:output].should == @now
|
671
|
+
end
|
672
|
+
|
673
|
+
it "should return the number of Affected Rows" do
|
674
|
+
@db.call_mssql_sproc(:SequelTest, {:args => [@now, 1, :output, :output]})[:numrows].should == 1
|
675
|
+
end
|
676
|
+
|
677
|
+
it "should return the Result Code" do
|
678
|
+
@db.call_mssql_sproc(:SequelTest, {:args => [@now, 1, :output, :output]})[:result].should == 1
|
679
|
+
end
|
680
|
+
end unless DB.adapter_scheme == :odbc
|
@@ -60,15 +60,15 @@ describe "An Oracle database" do
|
|
60
60
|
|
61
61
|
specify "should have working view_exists?" do
|
62
62
|
begin
|
63
|
-
DB.view_exists?(:cats).should
|
63
|
+
DB.view_exists?(:cats).should == false
|
64
64
|
DB.create_view(:cats, DB[:categories])
|
65
|
-
DB.view_exists?(:cats).should
|
65
|
+
DB.view_exists?(:cats).should == true
|
66
66
|
om = DB.identifier_output_method
|
67
67
|
im = DB.identifier_input_method
|
68
68
|
DB.identifier_output_method = :reverse
|
69
69
|
DB.identifier_input_method = :reverse
|
70
|
-
DB.view_exists?(:STAC).should
|
71
|
-
DB.view_exists?(:cats).should
|
70
|
+
DB.view_exists?(:STAC).should == true
|
71
|
+
DB.view_exists?(:cats).should == false
|
72
72
|
ensure
|
73
73
|
DB.identifier_output_method = om
|
74
74
|
DB.identifier_input_method = im
|
@@ -32,21 +32,21 @@ describe "PostgreSQL", '#create_table' do
|
|
32
32
|
@db.transaction do
|
33
33
|
@db.create_table(:some_table, :temp => true, :on_commit => :drop){text :name}
|
34
34
|
end
|
35
|
-
@db.table_exists?(:some_table).should
|
35
|
+
@db.table_exists?(:some_table).should == false
|
36
36
|
|
37
37
|
@db.transaction do
|
38
38
|
@db.create_table(:some_table, :temp => true, :on_commit => :delete_rows){text :name}
|
39
39
|
@db[:some_table].insert('a')
|
40
40
|
end
|
41
|
-
@db.table_exists?(:some_table).should
|
42
|
-
@db[:some_table].empty?.should
|
41
|
+
@db.table_exists?(:some_table).should == true
|
42
|
+
@db[:some_table].empty?.should == true
|
43
43
|
|
44
44
|
@db.drop_table(:some_table)
|
45
45
|
@db.transaction do
|
46
46
|
@db.create_table(:some_table, :temp => true, :on_commit => :preserve_rows){text :name}
|
47
47
|
@db[:some_table].insert('a')
|
48
48
|
end
|
49
|
-
@db.table_exists?(:some_table).should
|
49
|
+
@db.table_exists?(:some_table).should == true
|
50
50
|
@db[:some_table].count.should == 1
|
51
51
|
@db.drop_table(:some_table)
|
52
52
|
end
|
@@ -56,7 +56,7 @@ describe "PostgreSQL", '#create_table' do
|
|
56
56
|
@db.transaction do
|
57
57
|
@db.create_table(:some_table, :temp => true, :on_commit => :drop, :as => 'select 1')
|
58
58
|
end
|
59
|
-
@db.table_exists?(:some_table).should
|
59
|
+
@db.table_exists?(:some_table).should == false
|
60
60
|
end
|
61
61
|
|
62
62
|
specify ":on_commit should raise error if not used on a temporary table" do
|
@@ -1688,7 +1688,7 @@ if DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG && DB.server_versio
|
|
1688
1688
|
['', nil].should include(payload)
|
1689
1689
|
called = true
|
1690
1690
|
end.should == 'foo'
|
1691
|
-
called.should
|
1691
|
+
called.should == true
|
1692
1692
|
|
1693
1693
|
# Check weird identifier names
|
1694
1694
|
called = false
|
@@ -1698,7 +1698,7 @@ if DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG && DB.server_versio
|
|
1698
1698
|
['', nil].should include(payload)
|
1699
1699
|
called = true
|
1700
1700
|
end.should == 'FOO bar'
|
1701
|
-
called.should
|
1701
|
+
called.should == true
|
1702
1702
|
|
1703
1703
|
# Check identifier symbols
|
1704
1704
|
called = false
|
@@ -1708,7 +1708,7 @@ if DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG && DB.server_versio
|
|
1708
1708
|
['', nil].should include(payload)
|
1709
1709
|
called = true
|
1710
1710
|
end.should == 'foo'
|
1711
|
-
called.should
|
1711
|
+
called.should == true
|
1712
1712
|
|
1713
1713
|
called = false
|
1714
1714
|
@db.listen('foo', :after_listen=>proc{@db.notify('foo', :payload=>'bar')}) do |ev, pid, payload|
|
@@ -1717,7 +1717,7 @@ if DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG && DB.server_versio
|
|
1717
1717
|
payload.should == 'bar'
|
1718
1718
|
called = true
|
1719
1719
|
end.should == 'foo'
|
1720
|
-
called.should
|
1720
|
+
called.should == true
|
1721
1721
|
|
1722
1722
|
@db.listen('foo', :after_listen=>proc{@db.notify('foo')}).should == 'foo'
|
1723
1723
|
|
@@ -1738,8 +1738,8 @@ if DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG && DB.server_versio
|
|
1738
1738
|
break
|
1739
1739
|
end
|
1740
1740
|
end.should be_nil
|
1741
|
-
called.should
|
1742
|
-
called2.should
|
1741
|
+
called.should == true
|
1742
|
+
called2.should == true
|
1743
1743
|
i.should == 1
|
1744
1744
|
end
|
1745
1745
|
|
@@ -1747,7 +1747,7 @@ if DB.adapter_scheme == :postgres && SEQUEL_POSTGRES_USES_PG && DB.server_versio
|
|
1747
1747
|
@db.listen('foo2', :timeout=>0.001).should == nil
|
1748
1748
|
called = false
|
1749
1749
|
@db.listen('foo2', :timeout=>0.001){|ev, pid, payload| called = true}.should == nil
|
1750
|
-
called.should
|
1750
|
+
called.should == false
|
1751
1751
|
i = 0
|
1752
1752
|
@db.listen('foo2', :timeout=>0.001, :loop=>proc{i+=1; throw :stop if i > 3}){|ev, pid, payload| called = true}.should == nil
|
1753
1753
|
i.should == 4
|
@@ -1787,7 +1787,7 @@ describe 'PostgreSQL special float handling' do
|
|
1787
1787
|
specify 'inserts NaN' do
|
1788
1788
|
nan = 0.0/0.0
|
1789
1789
|
@ds.insert(:value=>nan)
|
1790
|
-
@ds.all[0][:value].nan?.should
|
1790
|
+
@ds.all[0][:value].nan?.should == true
|
1791
1791
|
end
|
1792
1792
|
|
1793
1793
|
specify 'inserts +Infinity' do
|
@@ -2093,26 +2093,26 @@ describe 'PostgreSQL array handling' do
|
|
2093
2093
|
@db.create_table!(:items){column :i, 'integer[]'; column :i2, 'integer[]'; column :i3, 'integer[]'; column :i4, 'integer[]'; column :i5, 'integer[]'}
|
2094
2094
|
@ds.insert(Sequel.pg_array([1, 2, 3]), Sequel.pg_array([2, 1]), Sequel.pg_array([4, 4]), Sequel.pg_array([[5, 5], [4, 3]]), Sequel.pg_array([1, nil, 5]))
|
2095
2095
|
|
2096
|
-
@ds.get(Sequel.pg_array(:i) > :i3).should
|
2097
|
-
@ds.get(Sequel.pg_array(:i3) > :i).should
|
2096
|
+
@ds.get(Sequel.pg_array(:i) > :i3).should == false
|
2097
|
+
@ds.get(Sequel.pg_array(:i3) > :i).should == true
|
2098
2098
|
|
2099
|
-
@ds.get(Sequel.pg_array(:i) >= :i3).should
|
2100
|
-
@ds.get(Sequel.pg_array(:i) >= :i).should
|
2099
|
+
@ds.get(Sequel.pg_array(:i) >= :i3).should == false
|
2100
|
+
@ds.get(Sequel.pg_array(:i) >= :i).should == true
|
2101
2101
|
|
2102
|
-
@ds.get(Sequel.pg_array(:i3) < :i).should
|
2103
|
-
@ds.get(Sequel.pg_array(:i) < :i3).should
|
2102
|
+
@ds.get(Sequel.pg_array(:i3) < :i).should == false
|
2103
|
+
@ds.get(Sequel.pg_array(:i) < :i3).should == true
|
2104
2104
|
|
2105
|
-
@ds.get(Sequel.pg_array(:i3) <= :i).should
|
2106
|
-
@ds.get(Sequel.pg_array(:i) <= :i).should
|
2105
|
+
@ds.get(Sequel.pg_array(:i3) <= :i).should == false
|
2106
|
+
@ds.get(Sequel.pg_array(:i) <= :i).should == true
|
2107
2107
|
|
2108
|
-
@ds.get(Sequel.expr(5=>Sequel.pg_array(:i).any)).should
|
2109
|
-
@ds.get(Sequel.expr(1=>Sequel.pg_array(:i).any)).should
|
2108
|
+
@ds.get(Sequel.expr(5=>Sequel.pg_array(:i).any)).should == false
|
2109
|
+
@ds.get(Sequel.expr(1=>Sequel.pg_array(:i).any)).should == true
|
2110
2110
|
|
2111
|
-
@ds.get(Sequel.expr(1=>Sequel.pg_array(:i3).all)).should
|
2112
|
-
@ds.get(Sequel.expr(4=>Sequel.pg_array(:i3).all)).should
|
2111
|
+
@ds.get(Sequel.expr(1=>Sequel.pg_array(:i3).all)).should == false
|
2112
|
+
@ds.get(Sequel.expr(4=>Sequel.pg_array(:i3).all)).should == true
|
2113
2113
|
|
2114
|
-
@ds.get(Sequel.expr(1=>Sequel.pg_array(:i)[1..1].any)).should
|
2115
|
-
@ds.get(Sequel.expr(2=>Sequel.pg_array(:i)[1..1].any)).should
|
2114
|
+
@ds.get(Sequel.expr(1=>Sequel.pg_array(:i)[1..1].any)).should == true
|
2115
|
+
@ds.get(Sequel.expr(2=>Sequel.pg_array(:i)[1..1].any)).should == false
|
2116
2116
|
|
2117
2117
|
@ds.get(Sequel.pg_array(:i2)[1]).should == 2
|
2118
2118
|
@ds.get(Sequel.pg_array(:i2)[1]).should == 2
|
@@ -2121,14 +2121,14 @@ describe 'PostgreSQL array handling' do
|
|
2121
2121
|
@ds.get(Sequel.pg_array(:i4)[2][1]).should == 4
|
2122
2122
|
@ds.get(Sequel.pg_array(:i4)[2][2]).should == 3
|
2123
2123
|
|
2124
|
-
@ds.get(Sequel.pg_array(:i).contains(:i2)).should
|
2125
|
-
@ds.get(Sequel.pg_array(:i).contains(:i3)).should
|
2124
|
+
@ds.get(Sequel.pg_array(:i).contains(:i2)).should == true
|
2125
|
+
@ds.get(Sequel.pg_array(:i).contains(:i3)).should == false
|
2126
2126
|
|
2127
|
-
@ds.get(Sequel.pg_array(:i2).contained_by(:i)).should
|
2128
|
-
@ds.get(Sequel.pg_array(:i).contained_by(:i2)).should
|
2127
|
+
@ds.get(Sequel.pg_array(:i2).contained_by(:i)).should == true
|
2128
|
+
@ds.get(Sequel.pg_array(:i).contained_by(:i2)).should == false
|
2129
2129
|
|
2130
|
-
@ds.get(Sequel.pg_array(:i).overlaps(:i2)).should
|
2131
|
-
@ds.get(Sequel.pg_array(:i2).overlaps(:i3)).should
|
2130
|
+
@ds.get(Sequel.pg_array(:i).overlaps(:i2)).should == true
|
2131
|
+
@ds.get(Sequel.pg_array(:i2).overlaps(:i3)).should == false
|
2132
2132
|
|
2133
2133
|
@ds.get(Sequel.pg_array(:i).dims).should == '[1:3]'
|
2134
2134
|
@ds.get(Sequel.pg_array(:i).length).should == 3
|
@@ -2144,8 +2144,8 @@ describe 'PostgreSQL array handling' do
|
|
2144
2144
|
end
|
2145
2145
|
if @db.server_version >= 90300
|
2146
2146
|
@ds.get(Sequel.pg_array(:i5).remove(1).length).should == 2
|
2147
|
-
@ds.get(Sequel.pg_array(:i5).replace(1, 4).contains([1])).should
|
2148
|
-
@ds.get(Sequel.pg_array(:i5).replace(1, 4).contains([4])).should
|
2147
|
+
@ds.get(Sequel.pg_array(:i5).replace(1, 4).contains([1])).should == false
|
2148
|
+
@ds.get(Sequel.pg_array(:i5).replace(1, 4).contains([4])).should == true
|
2149
2149
|
end
|
2150
2150
|
|
2151
2151
|
if @native
|
@@ -2616,7 +2616,7 @@ describe 'PostgreSQL inet/cidr types' do
|
|
2616
2616
|
@ds.count.should == 1
|
2617
2617
|
if @native
|
2618
2618
|
rs = @ds.all
|
2619
|
-
rs.first.values.all?{|c| c.is_a?(Sequel::Postgres::PGArray)}.should
|
2619
|
+
rs.first.values.all?{|c| c.is_a?(Sequel::Postgres::PGArray)}.should == true
|
2620
2620
|
rs.first[:i].first.should == @ipv4
|
2621
2621
|
rs.first[:c].first.should == @ipv4nm
|
2622
2622
|
rs.first[:m].first.should == '12:34:56:78:90:ab'
|
@@ -2775,70 +2775,70 @@ describe 'PostgreSQL range types' do
|
|
2775
2775
|
specify 'operations/functions with pg_range_ops' do
|
2776
2776
|
Sequel.extension :pg_range_ops
|
2777
2777
|
|
2778
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.contains(2..4)).should
|
2779
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.contains(3..6)).should
|
2780
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.contains(0..6)).should
|
2778
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.contains(2..4)).should == true
|
2779
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.contains(3..6)).should == false
|
2780
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.contains(0..6)).should == false
|
2781
2781
|
|
2782
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.contained_by(0..6)).should
|
2783
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.contained_by(3..6)).should
|
2784
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.contained_by(2..4)).should
|
2782
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.contained_by(0..6)).should == true
|
2783
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.contained_by(3..6)).should == false
|
2784
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.contained_by(2..4)).should == false
|
2785
2785
|
|
2786
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.overlaps(5..6)).should
|
2787
|
-
@db.get(Sequel.pg_range(1...5, :int4range).op.overlaps(5..6)).should
|
2786
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.overlaps(5..6)).should == true
|
2787
|
+
@db.get(Sequel.pg_range(1...5, :int4range).op.overlaps(5..6)).should == false
|
2788
2788
|
|
2789
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.left_of(6..10)).should
|
2790
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.left_of(5..10)).should
|
2791
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.left_of(-1..0)).should
|
2792
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.left_of(-1..3)).should
|
2793
|
-
|
2794
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.right_of(6..10)).should
|
2795
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.right_of(5..10)).should
|
2796
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.right_of(-1..0)).should
|
2797
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.right_of(-1..3)).should
|
2798
|
-
|
2799
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.ends_before(6..10)).should
|
2800
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.ends_before(5..10)).should
|
2801
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.ends_before(-1..0)).should
|
2802
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.ends_before(-1..3)).should
|
2803
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.ends_before(-1..7)).should
|
2804
|
-
|
2805
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.starts_after(6..10)).should
|
2806
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.starts_after(5..10)).should
|
2807
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.starts_after(3..10)).should
|
2808
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.starts_after(-1..10)).should
|
2809
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.starts_after(-1..0)).should
|
2810
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.starts_after(-1..3)).should
|
2811
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.starts_after(-5..-1)).should
|
2812
|
-
|
2813
|
-
@db.get(Sequel.pg_range(1..5, :int4range).op.adjacent_to(6..10)).should
|
2814
|
-
@db.get(Sequel.pg_range(1...5, :int4range).op.adjacent_to(6..10)).should
|
2815
|
-
|
2816
|
-
@db.get((Sequel.pg_range(1..5, :int4range).op + (6..10)).adjacent_to(6..10)).should
|
2817
|
-
@db.get((Sequel.pg_range(1..5, :int4range).op + (6..10)).adjacent_to(11..20)).should
|
2818
|
-
|
2819
|
-
@db.get((Sequel.pg_range(1..5, :int4range).op * (2..6)).adjacent_to(6..10)).should
|
2820
|
-
@db.get((Sequel.pg_range(1..4, :int4range).op * (2..6)).adjacent_to(6..10)).should
|
2821
|
-
|
2822
|
-
@db.get((Sequel.pg_range(1..5, :int4range).op - (2..6)).adjacent_to(2..10)).should
|
2823
|
-
@db.get((Sequel.pg_range(0..4, :int4range).op - (3..6)).adjacent_to(4..10)).should
|
2789
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.left_of(6..10)).should == true
|
2790
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.left_of(5..10)).should == false
|
2791
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.left_of(-1..0)).should == false
|
2792
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.left_of(-1..3)).should == false
|
2793
|
+
|
2794
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.right_of(6..10)).should == false
|
2795
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.right_of(5..10)).should == false
|
2796
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.right_of(-1..0)).should == true
|
2797
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.right_of(-1..3)).should == false
|
2798
|
+
|
2799
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.ends_before(6..10)).should == true
|
2800
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.ends_before(5..10)).should == true
|
2801
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.ends_before(-1..0)).should == false
|
2802
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.ends_before(-1..3)).should == false
|
2803
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.ends_before(-1..7)).should == true
|
2804
|
+
|
2805
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.starts_after(6..10)).should == false
|
2806
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.starts_after(5..10)).should == false
|
2807
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.starts_after(3..10)).should == false
|
2808
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.starts_after(-1..10)).should == true
|
2809
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.starts_after(-1..0)).should == true
|
2810
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.starts_after(-1..3)).should == true
|
2811
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.starts_after(-5..-1)).should == true
|
2812
|
+
|
2813
|
+
@db.get(Sequel.pg_range(1..5, :int4range).op.adjacent_to(6..10)).should == true
|
2814
|
+
@db.get(Sequel.pg_range(1...5, :int4range).op.adjacent_to(6..10)).should == false
|
2815
|
+
|
2816
|
+
@db.get((Sequel.pg_range(1..5, :int4range).op + (6..10)).adjacent_to(6..10)).should == false
|
2817
|
+
@db.get((Sequel.pg_range(1..5, :int4range).op + (6..10)).adjacent_to(11..20)).should == true
|
2818
|
+
|
2819
|
+
@db.get((Sequel.pg_range(1..5, :int4range).op * (2..6)).adjacent_to(6..10)).should == true
|
2820
|
+
@db.get((Sequel.pg_range(1..4, :int4range).op * (2..6)).adjacent_to(6..10)).should == false
|
2821
|
+
|
2822
|
+
@db.get((Sequel.pg_range(1..5, :int4range).op - (2..6)).adjacent_to(2..10)).should == true
|
2823
|
+
@db.get((Sequel.pg_range(0..4, :int4range).op - (3..6)).adjacent_to(4..10)).should == false
|
2824
2824
|
|
2825
2825
|
@db.get(Sequel.pg_range(0..4, :int4range).op.lower).should == 0
|
2826
2826
|
@db.get(Sequel.pg_range(0..4, :int4range).op.upper).should == 5
|
2827
2827
|
|
2828
|
-
@db.get(Sequel.pg_range(0..4, :int4range).op.isempty).should
|
2829
|
-
@db.get(Sequel::Postgres::PGRange.empty(:int4range).op.isempty).should
|
2828
|
+
@db.get(Sequel.pg_range(0..4, :int4range).op.isempty).should == false
|
2829
|
+
@db.get(Sequel::Postgres::PGRange.empty(:int4range).op.isempty).should == true
|
2830
2830
|
|
2831
|
-
@db.get(Sequel.pg_range(1..5, :numrange).op.lower_inc).should
|
2832
|
-
@db.get(Sequel::Postgres::PGRange.new(1, 5, :exclude_begin=>true, :db_type=>:numrange).op.lower_inc).should
|
2831
|
+
@db.get(Sequel.pg_range(1..5, :numrange).op.lower_inc).should == true
|
2832
|
+
@db.get(Sequel::Postgres::PGRange.new(1, 5, :exclude_begin=>true, :db_type=>:numrange).op.lower_inc).should == false
|
2833
2833
|
|
2834
|
-
@db.get(Sequel.pg_range(1..5, :numrange).op.upper_inc).should
|
2835
|
-
@db.get(Sequel.pg_range(1...5, :numrange).op.upper_inc).should
|
2834
|
+
@db.get(Sequel.pg_range(1..5, :numrange).op.upper_inc).should == true
|
2835
|
+
@db.get(Sequel.pg_range(1...5, :numrange).op.upper_inc).should == false
|
2836
2836
|
|
2837
|
-
@db.get(Sequel::Postgres::PGRange.new(1, 5, :db_type=>:int4range).op.lower_inf).should
|
2838
|
-
@db.get(Sequel::Postgres::PGRange.new(nil, 5, :db_type=>:int4range).op.lower_inf).should
|
2837
|
+
@db.get(Sequel::Postgres::PGRange.new(1, 5, :db_type=>:int4range).op.lower_inf).should == false
|
2838
|
+
@db.get(Sequel::Postgres::PGRange.new(nil, 5, :db_type=>:int4range).op.lower_inf).should == true
|
2839
2839
|
|
2840
|
-
@db.get(Sequel::Postgres::PGRange.new(1, 5, :db_type=>:int4range).op.upper_inf).should
|
2841
|
-
@db.get(Sequel::Postgres::PGRange.new(1, nil, :db_type=>:int4range).op.upper_inf).should
|
2840
|
+
@db.get(Sequel::Postgres::PGRange.new(1, 5, :db_type=>:int4range).op.upper_inf).should == false
|
2841
|
+
@db.get(Sequel::Postgres::PGRange.new(1, nil, :db_type=>:int4range).op.upper_inf).should == true
|
2842
2842
|
end
|
2843
2843
|
end if DB.server_version >= 90200
|
2844
2844
|
|
@@ -2882,7 +2882,7 @@ describe 'PostgreSQL interval types' do
|
|
2882
2882
|
if @native
|
2883
2883
|
@ds.get(Sequel.cast(:i, String)).should == outstr
|
2884
2884
|
rs = @ds.all
|
2885
|
-
rs.first[:i].is_a?(ActiveSupport::Duration).should
|
2885
|
+
rs.first[:i].is_a?(ActiveSupport::Duration).should == true
|
2886
2886
|
rs.first[:i].should == ActiveSupport::Duration.new(value, parts)
|
2887
2887
|
rs.first[:i].parts.sort_by{|k,v| k.to_s}.reject{|k,v| v == 0}.should == parts.sort_by{|k,v| k.to_s}
|
2888
2888
|
@ds.delete
|
@@ -2899,8 +2899,8 @@ describe 'PostgreSQL interval types' do
|
|
2899
2899
|
@ds.count.should == 1
|
2900
2900
|
if @native
|
2901
2901
|
rs = @ds.all
|
2902
|
-
rs.first[:i].is_a?(Sequel::Postgres::PGArray).should
|
2903
|
-
rs.first[:i].first.is_a?(ActiveSupport::Duration).should
|
2902
|
+
rs.first[:i].is_a?(Sequel::Postgres::PGArray).should == true
|
2903
|
+
rs.first[:i].first.is_a?(ActiveSupport::Duration).should == true
|
2904
2904
|
rs.first[:i].first.should == ActiveSupport::Duration.new(31557600 + 2*86400*30 + 3*86400*7 + 4*86400 + 5*3600 + 6*60 + 7, [[:years, 1], [:months, 2], [:days, 25], [:seconds, 18367]])
|
2905
2905
|
rs.first[:i].first.parts.sort_by{|k,v| k.to_s}.should == [[:years, 1], [:months, 2], [:days, 25], [:seconds, 18367]].sort_by{|k,v| k.to_s}
|
2906
2906
|
@ds.delete
|
@@ -2936,7 +2936,7 @@ describe 'PostgreSQL interval types' do
|
|
2936
2936
|
c = Class.new(Sequel::Model(@db[:items]))
|
2937
2937
|
c.plugin :pg_typecast_on_load, :i, :c unless @native
|
2938
2938
|
v = c.create(:i=>'1 year 2 mons 25 days 05:06:07').i
|
2939
|
-
v.is_a?(ActiveSupport::Duration).should
|
2939
|
+
v.is_a?(ActiveSupport::Duration).should == true
|
2940
2940
|
v.should == ActiveSupport::Duration.new(31557600 + 2*86400*30 + 3*86400*7 + 4*86400 + 5*3600 + 6*60 + 7, [[:years, 1], [:months, 2], [:days, 25], [:seconds, 18367]])
|
2941
2941
|
v.parts.sort_by{|k,_| k.to_s}.should == [[:years, 1], [:months, 2], [:days, 25], [:seconds, 18367]].sort_by{|k,_| k.to_s}
|
2942
2942
|
end
|
@@ -24,7 +24,9 @@ class Sequel::Database
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
(
|
27
|
+
require File.join(File.dirname(File.expand_path(__FILE__)), "../rspec_helper.rb")
|
28
|
+
|
29
|
+
RSPEC_EXAMPLE_GROUP.class_eval do
|
28
30
|
def log
|
29
31
|
begin
|
30
32
|
DB.loggers << Logger.new(STDOUT)
|
data/spec/bin_spec.rb
CHANGED
@@ -26,6 +26,8 @@ DB2 = Sequel.connect("#{CONN_PREFIX}#{BIN_SPEC_DB2}")
|
|
26
26
|
File.delete(BIN_SPEC_DB) if File.file?(BIN_SPEC_DB)
|
27
27
|
File.delete(BIN_SPEC_DB2) if File.file?(BIN_SPEC_DB2)
|
28
28
|
|
29
|
+
require File.join(File.dirname(File.expand_path(__FILE__)), "rspec_helper.rb")
|
30
|
+
|
29
31
|
describe "bin/sequel" do
|
30
32
|
def bin(opts={})
|
31
33
|
cmd = "#{opts[:pre]}\"#{RUBY}\" -I lib bin/sequel #{opts[:args]} #{"#{CONN_PREFIX}#{BIN_SPEC_DB}" unless opts[:no_conn]} #{opts[:post]}> #{OUTPUT}#{" 2>&1" if opts[:stderr]}"
|
data/spec/core/database_spec.rb
CHANGED
@@ -483,18 +483,18 @@ describe "Database#disconnect_connection" do
|
|
483
483
|
o = Object.new
|
484
484
|
def o.close() @closed=true end
|
485
485
|
Sequel::Database.new.disconnect_connection(o)
|
486
|
-
o.instance_variable_get(:@closed).should
|
486
|
+
o.instance_variable_get(:@closed).should == true
|
487
487
|
end
|
488
488
|
end
|
489
489
|
|
490
490
|
describe "Database#valid_connection?" do
|
491
491
|
specify "should issue a query to validate the connection" do
|
492
492
|
db = Sequel.mock
|
493
|
-
db.synchronize{|c| db.valid_connection?(c)}.should
|
493
|
+
db.synchronize{|c| db.valid_connection?(c)}.should == true
|
494
494
|
db.synchronize do |c|
|
495
495
|
def c.execute(*) raise Sequel::DatabaseError, "error" end
|
496
496
|
db.valid_connection?(c)
|
497
|
-
end.should
|
497
|
+
end.should == false
|
498
498
|
end
|
499
499
|
end
|
500
500
|
|
@@ -581,7 +581,7 @@ describe "Database#test_connection" do
|
|
581
581
|
end
|
582
582
|
|
583
583
|
specify "should return true if successful" do
|
584
|
-
@db.test_connection.should
|
584
|
+
@db.test_connection.should == true
|
585
585
|
end
|
586
586
|
|
587
587
|
specify "should raise an error if the attempting to connect raises an error" do
|
@@ -593,10 +593,10 @@ end
|
|
593
593
|
describe "Database#table_exists?" do
|
594
594
|
specify "should test existence by selecting a row from the table's dataset" do
|
595
595
|
db = Sequel.mock(:fetch=>[Sequel::Error, [], [{:a=>1}]])
|
596
|
-
db.table_exists?(:a).should
|
596
|
+
db.table_exists?(:a).should == false
|
597
597
|
db.sqls.should == ["SELECT NULL AS nil FROM a LIMIT 1"]
|
598
|
-
db.table_exists?(:b).should
|
599
|
-
db.table_exists?(:c).should
|
598
|
+
db.table_exists?(:b).should == true
|
599
|
+
db.table_exists?(:c).should == true
|
600
600
|
end
|
601
601
|
end
|
602
602
|
|
@@ -746,7 +746,7 @@ shared_examples_for "Database#transaction" do
|
|
746
746
|
specify "should have in_transaction? return true if inside a transaction" do
|
747
747
|
c = nil
|
748
748
|
@db.transaction{c = @db.in_transaction?}
|
749
|
-
c.should
|
749
|
+
c.should == true
|
750
750
|
end
|
751
751
|
|
752
752
|
specify "should have in_transaction? handle sharding correctly" do
|
@@ -757,7 +757,7 @@ shared_examples_for "Database#transaction" do
|
|
757
757
|
end
|
758
758
|
|
759
759
|
specify "should have in_transaction? return false if not in a transaction" do
|
760
|
-
@db.in_transaction?.should
|
760
|
+
@db.in_transaction?.should == false
|
761
761
|
end
|
762
762
|
|
763
763
|
specify "should return nil if Sequel::Rollback is called in the transaction" do
|
@@ -1741,16 +1741,16 @@ describe "Database#typecast_value" do
|
|
1741
1741
|
end
|
1742
1742
|
|
1743
1743
|
specify "should typecast boolean values to true, false, or nil" do
|
1744
|
-
@db.typecast_value(:boolean, false).should
|
1745
|
-
@db.typecast_value(:boolean, 0).should
|
1746
|
-
@db.typecast_value(:boolean, "0").should
|
1747
|
-
@db.typecast_value(:boolean, 'f').should
|
1748
|
-
@db.typecast_value(:boolean, 'false').should
|
1749
|
-
@db.typecast_value(:boolean, true).should
|
1750
|
-
@db.typecast_value(:boolean, 1).should
|
1751
|
-
@db.typecast_value(:boolean, '1').should
|
1752
|
-
@db.typecast_value(:boolean, 't').should
|
1753
|
-
@db.typecast_value(:boolean, 'true').should
|
1744
|
+
@db.typecast_value(:boolean, false).should == false
|
1745
|
+
@db.typecast_value(:boolean, 0).should == false
|
1746
|
+
@db.typecast_value(:boolean, "0").should == false
|
1747
|
+
@db.typecast_value(:boolean, 'f').should == false
|
1748
|
+
@db.typecast_value(:boolean, 'false').should == false
|
1749
|
+
@db.typecast_value(:boolean, true).should == true
|
1750
|
+
@db.typecast_value(:boolean, 1).should == true
|
1751
|
+
@db.typecast_value(:boolean, '1').should == true
|
1752
|
+
@db.typecast_value(:boolean, 't').should == true
|
1753
|
+
@db.typecast_value(:boolean, 'true').should == true
|
1754
1754
|
@db.typecast_value(:boolean, '').should be_nil
|
1755
1755
|
end
|
1756
1756
|
|
@@ -2326,13 +2326,13 @@ describe "Database extensions" do
|
|
2326
2326
|
specify "should be able to register an extension with a block and have Database#extension call the block" do
|
2327
2327
|
@db.quote_identifiers = false
|
2328
2328
|
Sequel::Database.register_extension(:foo){|db| db.quote_identifiers = true}
|
2329
|
-
@db.extension(:foo).quote_identifiers?.should
|
2329
|
+
@db.extension(:foo).quote_identifiers?.should == true
|
2330
2330
|
end
|
2331
2331
|
|
2332
2332
|
specify "should be able to register an extension with a callable and Database#extension call the callable" do
|
2333
2333
|
@db.quote_identifiers = false
|
2334
2334
|
Sequel::Database.register_extension(:foo, proc{|db| db.quote_identifiers = true})
|
2335
|
-
@db.extension(:foo).quote_identifiers?.should
|
2335
|
+
@db.extension(:foo).quote_identifiers?.should == true
|
2336
2336
|
end
|
2337
2337
|
|
2338
2338
|
specify "should be able to load multiple extensions in the same call" do
|
@@ -2341,7 +2341,7 @@ describe "Database extensions" do
|
|
2341
2341
|
Sequel::Database.register_extension(:foo, proc{|db| db.quote_identifiers = true})
|
2342
2342
|
Sequel::Database.register_extension(:bar, proc{|db| db.identifier_input_method = nil})
|
2343
2343
|
@db.extension(:foo, :bar)
|
2344
|
-
@db.quote_identifiers?.should
|
2344
|
+
@db.quote_identifiers?.should == true
|
2345
2345
|
@db.identifier_input_method.should be_nil
|
2346
2346
|
end
|
2347
2347
|
|