sequel 4.5.0 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -195,6 +195,12 @@ describe "Simple Dataset operations" do
|
|
195
195
|
@ds.limit(2, 1).all.should == []
|
196
196
|
end
|
197
197
|
|
198
|
+
specify "should be orderable by column number" do
|
199
|
+
@ds.insert(:number=>20)
|
200
|
+
@ds.insert(:number=>10)
|
201
|
+
@ds.order(2, 1).select_map([:id, :number]).should == [[1, 10], [3, 10], [2, 20]]
|
202
|
+
end
|
203
|
+
|
198
204
|
specify "should fetch correctly with a limit in an IN subselect" do
|
199
205
|
@ds.where(:id=>@ds.select(:id).order(:id).limit(2)).all.should == [{:id=>1, :number=>10}]
|
200
206
|
@ds.insert(:number=>20)
|
@@ -13,66 +13,66 @@ describe Sequel::Migrator do
|
|
13
13
|
specify "should be able to migrate up and down all the way successfully" do
|
14
14
|
@dir = 'spec/files/integer_migrations'
|
15
15
|
@m.apply(@db, @dir)
|
16
|
-
[:schema_info, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should
|
16
|
+
[:schema_info, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should == true}
|
17
17
|
@db[:schema_info].get(:version).should == 3
|
18
18
|
@m.apply(@db, @dir, 0)
|
19
|
-
[:sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should
|
19
|
+
[:sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should == false}
|
20
20
|
@db[:schema_info].get(:version).should == 0
|
21
21
|
end
|
22
22
|
|
23
23
|
specify "should be able to migrate up and down to specific versions successfully" do
|
24
24
|
@dir = 'spec/files/integer_migrations'
|
25
25
|
@m.apply(@db, @dir, 2)
|
26
|
-
[:schema_info, :sm1111, :sm2222].each{|n| @db.table_exists?(n).should
|
27
|
-
@db.table_exists?(:sm3333).should
|
26
|
+
[:schema_info, :sm1111, :sm2222].each{|n| @db.table_exists?(n).should == true}
|
27
|
+
@db.table_exists?(:sm3333).should == false
|
28
28
|
@db[:schema_info].get(:version).should == 2
|
29
29
|
@m.apply(@db, @dir, 1)
|
30
|
-
[:sm2222, :sm3333].each{|n| @db.table_exists?(n).should
|
31
|
-
@db.table_exists?(:sm1111).should
|
30
|
+
[:sm2222, :sm3333].each{|n| @db.table_exists?(n).should == false}
|
31
|
+
@db.table_exists?(:sm1111).should == true
|
32
32
|
@db[:schema_info].get(:version).should == 1
|
33
33
|
end
|
34
34
|
|
35
35
|
specify "should correctly set migration version to the last successful migration if the migration raises an error when migrating up" do
|
36
36
|
@dir = 'spec/files/bad_up_migration'
|
37
37
|
proc{@m.apply(@db, @dir)}.should raise_error
|
38
|
-
[:schema_info, :sm11111].each{|n| @db.table_exists?(n).should
|
39
|
-
@db.table_exists?(:sm22222).should
|
38
|
+
[:schema_info, :sm11111].each{|n| @db.table_exists?(n).should == true}
|
39
|
+
@db.table_exists?(:sm22222).should == false
|
40
40
|
@db[:schema_info].get(:version).should == 1
|
41
41
|
@m.apply(@db, @dir, 0)
|
42
|
-
[:sm11111, :sm22222].each{|n| @db.table_exists?(n).should
|
42
|
+
[:sm11111, :sm22222].each{|n| @db.table_exists?(n).should == false}
|
43
43
|
@db[:schema_info].get(:version).should == 0
|
44
44
|
end
|
45
45
|
|
46
46
|
specify "should correctly set migration version to the last successful migration if the migration raises an error when migrating down" do
|
47
47
|
@dir = 'spec/files/bad_down_migration'
|
48
48
|
@m.apply(@db, @dir)
|
49
|
-
[:schema_info, :sm11111, :sm22222].each{|n| @db.table_exists?(n).should
|
49
|
+
[:schema_info, :sm11111, :sm22222].each{|n| @db.table_exists?(n).should == true}
|
50
50
|
@db[:schema_info].get(:version).should == 2
|
51
51
|
proc{@m.apply(@db, @dir, 0)}.should raise_error
|
52
|
-
[:sm22222].each{|n| @db.table_exists?(n).should
|
53
|
-
@db.table_exists?(:sm11111).should
|
52
|
+
[:sm22222].each{|n| @db.table_exists?(n).should == false}
|
53
|
+
@db.table_exists?(:sm11111).should == true
|
54
54
|
@db[:schema_info].get(:version).should == 1
|
55
55
|
end
|
56
56
|
|
57
57
|
specify "should handle migrating up or down all the way with timestamped migrations" do
|
58
58
|
@dir = 'spec/files/timestamped_migrations'
|
59
59
|
@m.apply(@db, @dir)
|
60
|
-
[:schema_migrations, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should
|
60
|
+
[:schema_migrations, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should == true}
|
61
61
|
@db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb 1273253851_create_nodes.rb 1273253853_3_create_users.rb'
|
62
62
|
@m.apply(@db, @dir, 0)
|
63
|
-
[:sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should
|
63
|
+
[:sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should == false}
|
64
64
|
@db[:schema_migrations].select_order_map(:filename).should == []
|
65
65
|
end
|
66
66
|
|
67
67
|
specify "should handle migrating up or down to specific timestamps with timestamped migrations" do
|
68
68
|
@dir = 'spec/files/timestamped_migrations'
|
69
69
|
@m.apply(@db, @dir, 1273253851)
|
70
|
-
[:schema_migrations, :sm1111, :sm2222].each{|n| @db.table_exists?(n).should
|
71
|
-
@db.table_exists?(:sm3333).should
|
70
|
+
[:schema_migrations, :sm1111, :sm2222].each{|n| @db.table_exists?(n).should == true}
|
71
|
+
@db.table_exists?(:sm3333).should == false
|
72
72
|
@db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb 1273253851_create_nodes.rb'
|
73
73
|
@m.apply(@db, @dir, 1273253849)
|
74
|
-
[:sm2222, :sm3333].each{|n| @db.table_exists?(n).should
|
75
|
-
@db.table_exists?(:sm1111).should
|
74
|
+
[:sm2222, :sm3333].each{|n| @db.table_exists?(n).should == false}
|
75
|
+
@db.table_exists?(:sm1111).should == true
|
76
76
|
@db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb'
|
77
77
|
end
|
78
78
|
|
@@ -81,7 +81,7 @@ describe Sequel::Migrator do
|
|
81
81
|
@m.apply(@db, @dir)
|
82
82
|
@dir = 'spec/files/interleaved_timestamped_migrations'
|
83
83
|
@m.apply(@db, @dir)
|
84
|
-
[:schema_migrations, :sm1111, :sm1122, :sm2222, :sm2233, :sm3333].each{|n| @db.table_exists?(n).should
|
84
|
+
[:schema_migrations, :sm1111, :sm1122, :sm2222, :sm2233, :sm3333].each{|n| @db.table_exists?(n).should == true}
|
85
85
|
@db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb 1273253850_create_artists.rb 1273253851_create_nodes.rb 1273253852_create_albums.rb 1273253853_3_create_users.rb'
|
86
86
|
end
|
87
87
|
|
@@ -90,7 +90,7 @@ describe Sequel::Migrator do
|
|
90
90
|
@m.apply(@db, @dir)
|
91
91
|
@dir = 'spec/files/interleaved_timestamped_migrations'
|
92
92
|
@m.apply(@db, @dir, 0)
|
93
|
-
[:sm1111, :sm1122, :sm2222, :sm2233, :sm3333].each{|n| @db.table_exists?(n).should
|
93
|
+
[:sm1111, :sm1122, :sm2222, :sm2233, :sm3333].each{|n| @db.table_exists?(n).should == false}
|
94
94
|
@db[:schema_migrations].select_order_map(:filename).should == []
|
95
95
|
end
|
96
96
|
|
@@ -99,89 +99,89 @@ describe Sequel::Migrator do
|
|
99
99
|
@m.apply(@db, @dir)
|
100
100
|
@dir = 'spec/files/interleaved_timestamped_migrations'
|
101
101
|
@m.apply(@db, @dir, 1273253851)
|
102
|
-
[:schema_migrations, :sm1111, :sm1122, :sm2222].each{|n| @db.table_exists?(n).should
|
103
|
-
[:sm2233, :sm3333].each{|n| @db.table_exists?(n).should
|
102
|
+
[:schema_migrations, :sm1111, :sm1122, :sm2222].each{|n| @db.table_exists?(n).should == true}
|
103
|
+
[:sm2233, :sm3333].each{|n| @db.table_exists?(n).should == false}
|
104
104
|
@db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb 1273253850_create_artists.rb 1273253851_create_nodes.rb'
|
105
105
|
end
|
106
106
|
|
107
107
|
specify "should correctly update schema_migrations table when an error occurs when migrating up or down using timestamped migrations" do
|
108
108
|
@dir = 'spec/files/bad_timestamped_migrations'
|
109
109
|
proc{@m.apply(@db, @dir)}.should raise_error
|
110
|
-
[:schema_migrations, :sm1111, :sm2222].each{|n| @db.table_exists?(n).should
|
111
|
-
@db.table_exists?(:sm3333).should
|
110
|
+
[:schema_migrations, :sm1111, :sm2222].each{|n| @db.table_exists?(n).should == true}
|
111
|
+
@db.table_exists?(:sm3333).should == false
|
112
112
|
@db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb 1273253851_create_nodes.rb'
|
113
113
|
proc{@m.apply(@db, @dir, 0)}.should raise_error
|
114
|
-
[:sm2222, :sm3333].each{|n| @db.table_exists?(n).should
|
115
|
-
@db.table_exists?(:sm1111).should
|
114
|
+
[:sm2222, :sm3333].each{|n| @db.table_exists?(n).should == false}
|
115
|
+
@db.table_exists?(:sm1111).should == true
|
116
116
|
@db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb'
|
117
117
|
end
|
118
118
|
|
119
119
|
specify "should handle multiple migrations with the same timestamp correctly" do
|
120
120
|
@dir = 'spec/files/duplicate_timestamped_migrations'
|
121
121
|
@m.apply(@db, @dir)
|
122
|
-
[:schema_migrations, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should
|
122
|
+
[:schema_migrations, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should == true}
|
123
123
|
@db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb 1273253853_create_nodes.rb 1273253853_create_users.rb'
|
124
124
|
@m.apply(@db, @dir, 1273253853)
|
125
|
-
[:sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should
|
125
|
+
[:sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should == true}
|
126
126
|
@db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb 1273253853_create_nodes.rb 1273253853_create_users.rb'
|
127
127
|
@m.apply(@db, @dir, 1273253849)
|
128
|
-
[:sm1111].each{|n| @db.table_exists?(n).should
|
129
|
-
[:sm2222, :sm3333].each{|n| @db.table_exists?(n).should
|
128
|
+
[:sm1111].each{|n| @db.table_exists?(n).should == true}
|
129
|
+
[:sm2222, :sm3333].each{|n| @db.table_exists?(n).should == false}
|
130
130
|
@db[:schema_migrations].select_order_map(:filename).should == %w'1273253849_create_sessions.rb'
|
131
131
|
@m.apply(@db, @dir, 1273253848)
|
132
|
-
[:sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should
|
132
|
+
[:sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should == false}
|
133
133
|
@db[:schema_migrations].select_order_map(:filename).should == []
|
134
134
|
end
|
135
135
|
|
136
136
|
specify "should convert schema_info table to schema_migrations table" do
|
137
137
|
@dir = 'spec/files/integer_migrations'
|
138
138
|
@m.apply(@db, @dir)
|
139
|
-
[:schema_info, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should
|
140
|
-
[:schema_migrations, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should
|
139
|
+
[:schema_info, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should == true}
|
140
|
+
[:schema_migrations, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should == false}
|
141
141
|
|
142
142
|
@dir = 'spec/files/convert_to_timestamp_migrations'
|
143
143
|
@m.apply(@db, @dir)
|
144
|
-
[:schema_info, :sm1111, :sm2222, :sm3333, :schema_migrations, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should
|
144
|
+
[:schema_info, :sm1111, :sm2222, :sm3333, :schema_migrations, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should == true}
|
145
145
|
@db[:schema_migrations].select_order_map(:filename).should == %w'001_create_sessions.rb 002_create_nodes.rb 003_3_create_users.rb 1273253850_create_artists.rb 1273253852_create_albums.rb'
|
146
146
|
|
147
147
|
@m.apply(@db, @dir, 4)
|
148
|
-
[:schema_info, :schema_migrations, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should
|
149
|
-
[:sm1122, :sm2233].each{|n| @db.table_exists?(n).should
|
148
|
+
[:schema_info, :schema_migrations, :sm1111, :sm2222, :sm3333].each{|n| @db.table_exists?(n).should == true}
|
149
|
+
[:sm1122, :sm2233].each{|n| @db.table_exists?(n).should == false}
|
150
150
|
@db[:schema_migrations].select_order_map(:filename).should == %w'001_create_sessions.rb 002_create_nodes.rb 003_3_create_users.rb'
|
151
151
|
|
152
152
|
@m.apply(@db, @dir, 0)
|
153
|
-
[:schema_info, :schema_migrations].each{|n| @db.table_exists?(n).should
|
154
|
-
[:sm1111, :sm2222, :sm3333, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should
|
153
|
+
[:schema_info, :schema_migrations].each{|n| @db.table_exists?(n).should == true}
|
154
|
+
[:sm1111, :sm2222, :sm3333, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should == false}
|
155
155
|
@db[:schema_migrations].select_order_map(:filename).should == []
|
156
156
|
end
|
157
157
|
|
158
158
|
specify "should handle unapplied migrations when migrating schema_info table to schema_migrations table" do
|
159
159
|
@dir = 'spec/files/integer_migrations'
|
160
160
|
@m.apply(@db, @dir, 2)
|
161
|
-
[:schema_info, :sm1111, :sm2222].each{|n| @db.table_exists?(n).should
|
162
|
-
[:schema_migrations, :sm3333, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should
|
161
|
+
[:schema_info, :sm1111, :sm2222].each{|n| @db.table_exists?(n).should == true}
|
162
|
+
[:schema_migrations, :sm3333, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should == false}
|
163
163
|
|
164
164
|
@dir = 'spec/files/convert_to_timestamp_migrations'
|
165
165
|
@m.apply(@db, @dir, 1273253850)
|
166
|
-
[:schema_info, :sm1111, :sm2222, :sm3333, :schema_migrations, :sm1122].each{|n| @db.table_exists?(n).should
|
167
|
-
[:sm2233].each{|n| @db.table_exists?(n).should
|
166
|
+
[:schema_info, :sm1111, :sm2222, :sm3333, :schema_migrations, :sm1122].each{|n| @db.table_exists?(n).should == true}
|
167
|
+
[:sm2233].each{|n| @db.table_exists?(n).should == false}
|
168
168
|
@db[:schema_migrations].select_order_map(:filename).should == %w'001_create_sessions.rb 002_create_nodes.rb 003_3_create_users.rb 1273253850_create_artists.rb'
|
169
169
|
end
|
170
170
|
|
171
171
|
specify "should handle unapplied migrations when migrating schema_info table to schema_migrations table and target is less than last integer migration version" do
|
172
172
|
@dir = 'spec/files/integer_migrations'
|
173
173
|
@m.apply(@db, @dir, 1)
|
174
|
-
[:schema_info, :sm1111].each{|n| @db.table_exists?(n).should
|
175
|
-
[:schema_migrations, :sm2222, :sm3333, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should
|
174
|
+
[:schema_info, :sm1111].each{|n| @db.table_exists?(n).should == true}
|
175
|
+
[:schema_migrations, :sm2222, :sm3333, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should == false}
|
176
176
|
|
177
177
|
@dir = 'spec/files/convert_to_timestamp_migrations'
|
178
178
|
@m.apply(@db, @dir, 2)
|
179
|
-
[:schema_info, :sm1111, :sm2222, :schema_migrations].each{|n| @db.table_exists?(n).should
|
180
|
-
[:sm3333, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should
|
179
|
+
[:schema_info, :sm1111, :sm2222, :schema_migrations].each{|n| @db.table_exists?(n).should == true}
|
180
|
+
[:sm3333, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should == false}
|
181
181
|
@db[:schema_migrations].select_order_map(:filename).should == %w'001_create_sessions.rb 002_create_nodes.rb'
|
182
182
|
|
183
183
|
@m.apply(@db, @dir)
|
184
|
-
[:schema_info, :sm1111, :sm2222, :schema_migrations, :sm3333, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should
|
184
|
+
[:schema_info, :sm1111, :sm2222, :schema_migrations, :sm3333, :sm1122, :sm2233].each{|n| @db.table_exists?(n).should == true}
|
185
185
|
@db[:schema_migrations].select_order_map(:filename).should == %w'001_create_sessions.rb 002_create_nodes.rb 003_3_create_users.rb 1273253850_create_artists.rb 1273253852_create_albums.rb'
|
186
186
|
end
|
187
187
|
|
@@ -189,52 +189,52 @@ describe Sequel::Migrator do
|
|
189
189
|
@dir = 'spec/files/reversible_migrations'
|
190
190
|
@db.drop_table?(:a, :b)
|
191
191
|
@m.apply(@db, @dir, 1)
|
192
|
-
[:schema_info, :a].each{|n| @db.table_exists?(n).should
|
193
|
-
[:schema_migrations, :b].each{|n| @db.table_exists?(n).should
|
192
|
+
[:schema_info, :a].each{|n| @db.table_exists?(n).should == true}
|
193
|
+
[:schema_migrations, :b].each{|n| @db.table_exists?(n).should == false}
|
194
194
|
@db[:a].columns.should == [:a]
|
195
195
|
|
196
196
|
@m.apply(@db, @dir, 2)
|
197
|
-
[:schema_info, :a].each{|n| @db.table_exists?(n).should
|
198
|
-
[:schema_migrations, :b].each{|n| @db.table_exists?(n).should
|
197
|
+
[:schema_info, :a].each{|n| @db.table_exists?(n).should == true}
|
198
|
+
[:schema_migrations, :b].each{|n| @db.table_exists?(n).should == false}
|
199
199
|
@db[:a].columns.should == [:a, :b]
|
200
200
|
|
201
201
|
@m.apply(@db, @dir, 3)
|
202
|
-
[:schema_info, :a].each{|n| @db.table_exists?(n).should
|
203
|
-
[:schema_migrations, :b].each{|n| @db.table_exists?(n).should
|
202
|
+
[:schema_info, :a].each{|n| @db.table_exists?(n).should == true}
|
203
|
+
[:schema_migrations, :b].each{|n| @db.table_exists?(n).should == false}
|
204
204
|
@db[:a].columns.should == [:a, :c]
|
205
205
|
|
206
206
|
@m.apply(@db, @dir, 4)
|
207
|
-
[:schema_info, :b].each{|n| @db.table_exists?(n).should
|
208
|
-
[:schema_migrations, :a].each{|n| @db.table_exists?(n).should
|
207
|
+
[:schema_info, :b].each{|n| @db.table_exists?(n).should == true}
|
208
|
+
[:schema_migrations, :a].each{|n| @db.table_exists?(n).should == false}
|
209
209
|
@db[:b].columns.should == [:a, :c]
|
210
210
|
|
211
211
|
@m.apply(@db, @dir, 5)
|
212
|
-
[:schema_info, :b].each{|n| @db.table_exists?(n).should
|
213
|
-
[:schema_migrations, :a].each{|n| @db.table_exists?(n).should
|
212
|
+
[:schema_info, :b].each{|n| @db.table_exists?(n).should == true}
|
213
|
+
[:schema_migrations, :a].each{|n| @db.table_exists?(n).should == false}
|
214
214
|
@db[:b].columns.should == [:a, :c, :e]
|
215
215
|
|
216
216
|
@m.apply(@db, @dir, 4)
|
217
|
-
[:schema_info, :b].each{|n| @db.table_exists?(n).should
|
218
|
-
[:schema_migrations, :a].each{|n| @db.table_exists?(n).should
|
217
|
+
[:schema_info, :b].each{|n| @db.table_exists?(n).should == true}
|
218
|
+
[:schema_migrations, :a].each{|n| @db.table_exists?(n).should == false}
|
219
219
|
@db[:b].columns.should == [:a, :c]
|
220
220
|
|
221
221
|
@m.apply(@db, @dir, 3)
|
222
|
-
[:schema_info, :a].each{|n| @db.table_exists?(n).should
|
223
|
-
[:schema_migrations, :b].each{|n| @db.table_exists?(n).should
|
222
|
+
[:schema_info, :a].each{|n| @db.table_exists?(n).should == true}
|
223
|
+
[:schema_migrations, :b].each{|n| @db.table_exists?(n).should == false}
|
224
224
|
@db[:a].columns.should == [:a, :c]
|
225
225
|
|
226
226
|
@m.apply(@db, @dir, 2)
|
227
|
-
[:schema_info, :a].each{|n| @db.table_exists?(n).should
|
228
|
-
[:schema_migrations, :b].each{|n| @db.table_exists?(n).should
|
227
|
+
[:schema_info, :a].each{|n| @db.table_exists?(n).should == true}
|
228
|
+
[:schema_migrations, :b].each{|n| @db.table_exists?(n).should == false}
|
229
229
|
@db[:a].columns.should == [:a, :b]
|
230
230
|
|
231
231
|
@m.apply(@db, @dir, 1)
|
232
|
-
[:schema_info, :a].each{|n| @db.table_exists?(n).should
|
233
|
-
[:schema_migrations, :b].each{|n| @db.table_exists?(n).should
|
232
|
+
[:schema_info, :a].each{|n| @db.table_exists?(n).should == true}
|
233
|
+
[:schema_migrations, :b].each{|n| @db.table_exists?(n).should == false}
|
234
234
|
@db[:a].columns.should == [:a]
|
235
235
|
|
236
236
|
@m.apply(@db, @dir, 0)
|
237
|
-
[:schema_info].each{|n| @db.table_exists?(n).should
|
238
|
-
[:schema_migrations, :a, :b].each{|n| @db.table_exists?(n).should
|
237
|
+
[:schema_info].each{|n| @db.table_exists?(n).should == true}
|
238
|
+
[:schema_migrations, :a, :b].each{|n| @db.table_exists?(n).should == false}
|
239
239
|
end
|
240
240
|
end
|
@@ -107,7 +107,7 @@ describe "Sequel::Model basic support" do
|
|
107
107
|
|
108
108
|
i.rb = true
|
109
109
|
i.destroy.should be_nil
|
110
|
-
i.exists?.should
|
110
|
+
i.exists?.should == true
|
111
111
|
i.hooks.should == [:ad, :adr]
|
112
112
|
|
113
113
|
i.name = 'K'
|
@@ -118,7 +118,7 @@ describe "Sequel::Model basic support" do
|
|
118
118
|
|
119
119
|
i.rb = false
|
120
120
|
i.destroy.should_not be_nil
|
121
|
-
i.exists?.should
|
121
|
+
i.exists?.should == false
|
122
122
|
i.hooks.should == [:ad, :adc]
|
123
123
|
end
|
124
124
|
|
@@ -298,7 +298,7 @@ describe "Database schema modifiers" do
|
|
298
298
|
specify "should handle create table in a rolled back transaction" do
|
299
299
|
@db.drop_table?(:items)
|
300
300
|
@db.transaction(:rollback=>:always){@db.create_table(:items){Integer :number}}
|
301
|
-
@db.table_exists?(:items).should
|
301
|
+
@db.table_exists?(:items).should == false
|
302
302
|
end if DB.supports_transactional_ddl?
|
303
303
|
|
304
304
|
describe "join tables" do
|
@@ -60,7 +60,9 @@ def Sequel.guarded?(*checked)
|
|
60
60
|
false
|
61
61
|
end
|
62
62
|
|
63
|
-
(
|
63
|
+
require File.join(File.dirname(File.expand_path(__FILE__)), "../rspec_helper.rb")
|
64
|
+
|
65
|
+
RSPEC_EXAMPLE_GROUP.class_eval do
|
64
66
|
def log
|
65
67
|
begin
|
66
68
|
DB.loggers << Logger.new(STDOUT)
|
@@ -23,10 +23,10 @@ describe "Database transactions" do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
specify "should have #in_transaction? work correctly" do
|
26
|
-
@db.in_transaction?.should
|
26
|
+
@db.in_transaction?.should == false
|
27
27
|
c = nil
|
28
28
|
@db.transaction{c = @db.in_transaction?}
|
29
|
-
c.should
|
29
|
+
c.should == true
|
30
30
|
end
|
31
31
|
|
32
32
|
specify "should correctly rollback transactions" do
|
@@ -269,16 +269,16 @@ describe Sequel::Model::Associations::AssociationReflection, "#remove_before_des
|
|
269
269
|
|
270
270
|
it "should be true for many_to_one and many_to_many associations" do
|
271
271
|
@c.many_to_one :c, :class=>@c
|
272
|
-
@c.association_reflection(:c).remove_before_destroy?.should
|
272
|
+
@c.association_reflection(:c).remove_before_destroy?.should == true
|
273
273
|
@c.many_to_many :cs, :class=>@c
|
274
|
-
@c.association_reflection(:cs).remove_before_destroy?.should
|
274
|
+
@c.association_reflection(:cs).remove_before_destroy?.should == true
|
275
275
|
end
|
276
276
|
|
277
277
|
it "should be false for one_to_one and one_to_many associations" do
|
278
278
|
@c.one_to_one :c, :class=>@c
|
279
|
-
@c.association_reflection(:c).remove_before_destroy?.should
|
279
|
+
@c.association_reflection(:c).remove_before_destroy?.should == false
|
280
280
|
@c.one_to_many :cs, :class=>@c
|
281
|
-
@c.association_reflection(:cs).remove_before_destroy?.should
|
281
|
+
@c.association_reflection(:cs).remove_before_destroy?.should == false
|
282
282
|
end
|
283
283
|
end
|
284
284
|
|
@@ -3736,7 +3736,7 @@ describe "Model#freeze" do
|
|
3736
3736
|
end
|
3737
3737
|
|
3738
3738
|
it "should freeze the object's associations" do
|
3739
|
-
@o.associations.frozen?.should
|
3739
|
+
@o.associations.frozen?.should == true
|
3740
3740
|
end
|
3741
3741
|
|
3742
3742
|
it "should not break associations getters" do
|
@@ -25,7 +25,7 @@ describe Sequel::Model, "class dataset methods" do
|
|
25
25
|
@c.each{|r| r.should == @c.load(:id=>1)}.should == @d
|
26
26
|
@db.sqls.should == ["SELECT * FROM items"]
|
27
27
|
@c.each_server{|r| r.opts[:server].should == :default}
|
28
|
-
@c.empty?.should
|
28
|
+
@c.empty?.should == false
|
29
29
|
@db.sqls.should == ["SELECT 1 AS one FROM items LIMIT 1"]
|
30
30
|
@c.except(@d, :from_self=>false).sql.should == "SELECT * FROM items EXCEPT SELECT * FROM items"
|
31
31
|
@c.exclude(:a).sql.should == "SELECT * FROM items WHERE NOT a"
|
@@ -149,6 +149,13 @@ describe Sequel::Model, "#eager" do
|
|
149
149
|
DB.sqls.should == []
|
150
150
|
end
|
151
151
|
|
152
|
+
it "should not break if the dataset does not have a row proc" do
|
153
|
+
EagerAlbum.one_to_one :track, :class=>'EagerTrack', :key=>:album_id
|
154
|
+
a = EagerAlbum.eager(:track).naked.all
|
155
|
+
a.should == [{:id => 1, :band_id => 2}]
|
156
|
+
DB.sqls.should == ['SELECT * FROM albums']
|
157
|
+
end
|
158
|
+
|
152
159
|
it "should use first matching entry when eager loading one_to_one association" do
|
153
160
|
EagerAlbum.one_to_one :track, :class=>'EagerTrack', :key=>:album_id
|
154
161
|
EagerTrack.dataset._fetch = [{:id => 3, :album_id=>1}, {:id => 4, :album_id=>1}]
|
data/spec/model/model_spec.rb
CHANGED
@@ -303,7 +303,7 @@ describe Sequel::Model, "constructors" do
|
|
303
303
|
block_called = false
|
304
304
|
m = @m.new {|i| block_called = true; i.should be_a_kind_of(@m); i.values[:a] = 1}
|
305
305
|
|
306
|
-
block_called.should
|
306
|
+
block_called.should == true
|
307
307
|
m.values[:a].should == 1
|
308
308
|
end
|
309
309
|
|
@@ -312,21 +312,21 @@ describe Sequel::Model, "constructors" do
|
|
312
312
|
o = @m.dataset.row_proc.call(:a=>1)
|
313
313
|
o.should be_a_kind_of(@m)
|
314
314
|
o.values.should == {:a=>1}
|
315
|
-
o.new?.should
|
315
|
+
o.new?.should == false
|
316
316
|
end
|
317
317
|
|
318
318
|
it "should have .call create an existing object" do
|
319
319
|
o = @m.call(:a=>1)
|
320
320
|
o.should be_a_kind_of(@m)
|
321
321
|
o.values.should == {:a=>1}
|
322
|
-
o.new?.should
|
322
|
+
o.new?.should == false
|
323
323
|
end
|
324
324
|
|
325
325
|
it "should have .load create an existing object" do
|
326
326
|
o = @m.load(:a=>1)
|
327
327
|
o.should be_a_kind_of(@m)
|
328
328
|
o.values.should == {:a=>1}
|
329
|
-
o.new?.should
|
329
|
+
o.new?.should == false
|
330
330
|
end
|
331
331
|
end
|
332
332
|
|