sequel 3.47.0 → 3.48.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +230 -0
- data/README.rdoc +31 -40
- data/Rakefile +1 -14
- data/doc/active_record.rdoc +29 -29
- data/doc/association_basics.rdoc +4 -13
- data/doc/cheat_sheet.rdoc +8 -6
- data/doc/code_order.rdoc +89 -0
- data/doc/core_extensions.rdoc +3 -3
- data/doc/dataset_basics.rdoc +7 -8
- data/doc/dataset_filtering.rdoc +7 -2
- data/doc/mass_assignment.rdoc +2 -3
- data/doc/migration.rdoc +8 -8
- data/doc/model_hooks.rdoc +11 -7
- data/doc/object_model.rdoc +2 -2
- data/doc/opening_databases.rdoc +5 -14
- data/doc/prepared_statements.rdoc +5 -9
- data/doc/querying.rdoc +23 -28
- data/doc/reflection.rdoc +11 -0
- data/doc/release_notes/3.48.0.txt +477 -0
- data/doc/schema_modification.rdoc +12 -5
- data/doc/security.rdoc +2 -2
- data/doc/sharding.rdoc +1 -2
- data/doc/sql.rdoc +10 -13
- data/doc/testing.rdoc +8 -4
- data/doc/transactions.rdoc +2 -2
- data/doc/validations.rdoc +40 -17
- data/doc/virtual_rows.rdoc +2 -2
- data/lib/sequel/adapters/ado.rb +25 -20
- data/lib/sequel/adapters/ado/access.rb +1 -0
- data/lib/sequel/adapters/ado/mssql.rb +1 -0
- data/lib/sequel/adapters/db2.rb +9 -7
- data/lib/sequel/adapters/dbi.rb +16 -16
- data/lib/sequel/adapters/do.rb +17 -18
- data/lib/sequel/adapters/do/mysql.rb +1 -0
- data/lib/sequel/adapters/do/postgres.rb +2 -0
- data/lib/sequel/adapters/do/sqlite.rb +1 -0
- data/lib/sequel/adapters/firebird.rb +5 -7
- data/lib/sequel/adapters/ibmdb.rb +23 -20
- data/lib/sequel/adapters/informix.rb +8 -2
- data/lib/sequel/adapters/jdbc.rb +39 -35
- data/lib/sequel/adapters/jdbc/as400.rb +1 -0
- data/lib/sequel/adapters/jdbc/cubrid.rb +1 -0
- data/lib/sequel/adapters/jdbc/db2.rb +1 -0
- data/lib/sequel/adapters/jdbc/derby.rb +1 -0
- data/lib/sequel/adapters/jdbc/firebird.rb +1 -0
- data/lib/sequel/adapters/jdbc/h2.rb +1 -0
- data/lib/sequel/adapters/jdbc/hsqldb.rb +1 -0
- data/lib/sequel/adapters/jdbc/informix.rb +1 -0
- data/lib/sequel/adapters/jdbc/jtds.rb +1 -0
- data/lib/sequel/adapters/jdbc/mssql.rb +1 -0
- data/lib/sequel/adapters/jdbc/mysql.rb +1 -0
- data/lib/sequel/adapters/jdbc/oracle.rb +1 -0
- data/lib/sequel/adapters/jdbc/postgresql.rb +2 -0
- data/lib/sequel/adapters/jdbc/progress.rb +1 -0
- data/lib/sequel/adapters/jdbc/sqlite.rb +1 -0
- data/lib/sequel/adapters/jdbc/sqlserver.rb +1 -0
- data/lib/sequel/adapters/mock.rb +30 -31
- data/lib/sequel/adapters/mysql.rb +6 -7
- data/lib/sequel/adapters/mysql2.rb +5 -6
- data/lib/sequel/adapters/odbc.rb +22 -20
- data/lib/sequel/adapters/odbc/mssql.rb +1 -0
- data/lib/sequel/adapters/openbase.rb +4 -1
- data/lib/sequel/adapters/oracle.rb +10 -8
- data/lib/sequel/adapters/postgres.rb +12 -10
- data/lib/sequel/adapters/shared/access.rb +6 -0
- data/lib/sequel/adapters/shared/cubrid.rb +2 -0
- data/lib/sequel/adapters/shared/db2.rb +2 -0
- data/lib/sequel/adapters/shared/firebird.rb +2 -0
- data/lib/sequel/adapters/shared/informix.rb +2 -0
- data/lib/sequel/adapters/shared/mssql.rb +14 -8
- data/lib/sequel/adapters/shared/mysql.rb +6 -0
- data/lib/sequel/adapters/shared/oracle.rb +2 -0
- data/lib/sequel/adapters/shared/postgres.rb +14 -4
- data/lib/sequel/adapters/shared/progress.rb +1 -0
- data/lib/sequel/adapters/shared/sqlite.rb +4 -3
- data/lib/sequel/adapters/sqlite.rb +6 -7
- data/lib/sequel/adapters/swift.rb +20 -21
- data/lib/sequel/adapters/swift/mysql.rb +1 -0
- data/lib/sequel/adapters/swift/postgres.rb +2 -0
- data/lib/sequel/adapters/swift/sqlite.rb +1 -0
- data/lib/sequel/adapters/tinytds.rb +5 -6
- data/lib/sequel/adapters/utils/emulate_offset_with_reverse_and_count.rb +68 -0
- data/lib/sequel/connection_pool.rb +1 -1
- data/lib/sequel/core.rb +57 -50
- data/lib/sequel/database/connecting.rb +9 -10
- data/lib/sequel/database/dataset.rb +11 -6
- data/lib/sequel/database/dataset_defaults.rb +61 -69
- data/lib/sequel/database/features.rb +21 -0
- data/lib/sequel/database/misc.rb +23 -3
- data/lib/sequel/database/query.rb +13 -7
- data/lib/sequel/database/schema_methods.rb +6 -6
- data/lib/sequel/database/transactions.rb +1 -0
- data/lib/sequel/dataset/actions.rb +51 -38
- data/lib/sequel/dataset/features.rb +1 -0
- data/lib/sequel/dataset/graph.rb +9 -33
- data/lib/sequel/dataset/misc.rb +30 -5
- data/lib/sequel/dataset/mutation.rb +2 -3
- data/lib/sequel/dataset/prepared_statements.rb +1 -1
- data/lib/sequel/dataset/query.rb +91 -27
- data/lib/sequel/dataset/sql.rb +40 -6
- data/lib/sequel/deprecated.rb +74 -0
- data/lib/sequel/deprecated_core_extensions.rb +135 -0
- data/lib/sequel/extensions/columns_introspection.rb +1 -5
- data/lib/sequel/extensions/core_extensions.rb +10 -3
- data/lib/sequel/extensions/date_arithmetic.rb +1 -0
- data/lib/sequel/extensions/empty_array_ignore_nulls.rb +33 -0
- data/lib/sequel/extensions/filter_having.rb +58 -0
- data/lib/sequel/extensions/graph_each.rb +63 -0
- data/lib/sequel/extensions/hash_aliases.rb +44 -0
- data/lib/sequel/extensions/looser_typecasting.rb +14 -3
- data/lib/sequel/extensions/migration.rb +2 -3
- data/lib/sequel/extensions/named_timezones.rb +14 -1
- data/lib/sequel/extensions/null_dataset.rb +7 -1
- data/lib/sequel/extensions/pagination.rb +15 -5
- data/lib/sequel/extensions/pg_auto_parameterize.rb +1 -0
- data/lib/sequel/extensions/pg_hstore_ops.rb +48 -14
- data/lib/sequel/extensions/pg_json.rb +7 -7
- data/lib/sequel/extensions/pg_range_ops.rb +8 -2
- data/lib/sequel/extensions/pg_statement_cache.rb +1 -0
- data/lib/sequel/extensions/pretty_table.rb +13 -4
- data/lib/sequel/extensions/query.rb +21 -4
- data/lib/sequel/extensions/ruby18_symbol_extensions.rb +22 -0
- data/lib/sequel/extensions/schema_caching.rb +10 -7
- data/lib/sequel/extensions/schema_dumper.rb +35 -48
- data/lib/sequel/extensions/select_remove.rb +13 -4
- data/lib/sequel/extensions/sequel_3_dataset_methods.rb +117 -0
- data/lib/sequel/extensions/set_overrides.rb +43 -0
- data/lib/sequel/extensions/to_dot.rb +6 -0
- data/lib/sequel/model.rb +12 -6
- data/lib/sequel/model/associations.rb +80 -38
- data/lib/sequel/model/base.rb +137 -52
- data/lib/sequel/model/errors.rb +7 -2
- data/lib/sequel/plugins/active_model.rb +13 -0
- data/lib/sequel/plugins/after_initialize.rb +43 -0
- data/lib/sequel/plugins/association_proxies.rb +63 -7
- data/lib/sequel/plugins/auto_validations.rb +56 -16
- data/lib/sequel/plugins/blacklist_security.rb +63 -0
- data/lib/sequel/plugins/class_table_inheritance.rb +9 -0
- data/lib/sequel/plugins/constraint_validations.rb +50 -8
- data/lib/sequel/plugins/dataset_associations.rb +2 -0
- data/lib/sequel/plugins/hook_class_methods.rb +7 -1
- data/lib/sequel/plugins/identity_map.rb +4 -0
- data/lib/sequel/plugins/json_serializer.rb +32 -13
- data/lib/sequel/plugins/optimistic_locking.rb +1 -1
- data/lib/sequel/plugins/rcte_tree.rb +4 -4
- data/lib/sequel/plugins/scissors.rb +33 -0
- data/lib/sequel/plugins/serialization.rb +1 -1
- data/lib/sequel/plugins/single_table_inheritance.rb +6 -0
- data/lib/sequel/plugins/tree.rb +5 -1
- data/lib/sequel/plugins/validation_class_methods.rb +2 -1
- data/lib/sequel/plugins/validation_helpers.rb +15 -11
- data/lib/sequel/plugins/xml_serializer.rb +12 -3
- data/lib/sequel/sql.rb +12 -2
- data/lib/sequel/timezones.rb +1 -1
- data/lib/sequel/version.rb +1 -1
- data/lib/sequel_core.rb +1 -0
- data/lib/sequel_model.rb +1 -0
- data/spec/adapters/mssql_spec.rb +24 -57
- data/spec/adapters/postgres_spec.rb +27 -55
- data/spec/adapters/spec_helper.rb +1 -1
- data/spec/adapters/sqlite_spec.rb +1 -1
- data/spec/bin_spec.rb +251 -0
- data/spec/core/database_spec.rb +46 -32
- data/spec/core/dataset_spec.rb +233 -181
- data/spec/core/deprecated_spec.rb +78 -0
- data/spec/core/expression_filters_spec.rb +3 -4
- data/spec/core/mock_adapter_spec.rb +9 -9
- data/spec/core/object_graph_spec.rb +9 -19
- data/spec/core/schema_spec.rb +3 -1
- data/spec/core/spec_helper.rb +19 -0
- data/spec/core_extensions_spec.rb +80 -30
- data/spec/extensions/after_initialize_spec.rb +24 -0
- data/spec/extensions/association_proxies_spec.rb +37 -1
- data/spec/extensions/auto_validations_spec.rb +20 -4
- data/spec/extensions/blacklist_security_spec.rb +87 -0
- data/spec/extensions/boolean_readers_spec.rb +2 -1
- data/spec/extensions/class_table_inheritance_spec.rb +7 -0
- data/spec/extensions/columns_introspection_spec.rb +3 -3
- data/spec/extensions/constraint_validations_plugin_spec.rb +83 -5
- data/spec/extensions/core_refinements_spec.rb +7 -7
- data/spec/extensions/dataset_associations_spec.rb +2 -2
- data/spec/extensions/date_arithmetic_spec.rb +1 -1
- data/spec/extensions/defaults_setter_spec.rb +2 -1
- data/spec/extensions/empty_array_ignore_nulls_spec.rb +24 -0
- data/spec/extensions/filter_having_spec.rb +40 -0
- data/spec/extensions/graph_each_spec.rb +109 -0
- data/spec/extensions/hash_aliases_spec.rb +16 -0
- data/spec/extensions/hook_class_methods_spec.rb +2 -2
- data/spec/extensions/identity_map_spec.rb +3 -3
- data/spec/extensions/json_serializer_spec.rb +19 -19
- data/spec/extensions/lazy_attributes_spec.rb +1 -0
- data/spec/extensions/list_spec.rb +13 -13
- data/spec/extensions/looser_typecasting_spec.rb +10 -3
- data/spec/extensions/many_through_many_spec.rb +1 -1
- data/spec/extensions/migration_spec.rb +7 -7
- data/spec/extensions/named_timezones_spec.rb +6 -0
- data/spec/extensions/nested_attributes_spec.rb +2 -2
- data/spec/extensions/null_dataset_spec.rb +1 -1
- data/spec/extensions/pagination_spec.rb +2 -2
- data/spec/extensions/pg_hstore_ops_spec.rb +75 -0
- data/spec/extensions/pg_range_ops_spec.rb +4 -2
- data/spec/extensions/pg_row_plugin_spec.rb +1 -1
- data/spec/extensions/pretty_table_spec.rb +1 -1
- data/spec/extensions/query_literals_spec.rb +1 -1
- data/spec/extensions/query_spec.rb +3 -3
- data/spec/extensions/schema_caching_spec.rb +3 -3
- data/spec/extensions/schema_dumper_spec.rb +27 -2
- data/spec/extensions/schema_spec.rb +2 -2
- data/spec/extensions/scissors_spec.rb +26 -0
- data/spec/extensions/select_remove_spec.rb +1 -1
- data/spec/extensions/sequel_3_dataset_methods_spec.rb +102 -0
- data/spec/extensions/set_overrides_spec.rb +45 -0
- data/spec/extensions/single_table_inheritance_spec.rb +10 -0
- data/spec/extensions/spec_helper.rb +24 -1
- data/spec/extensions/static_cache_spec.rb +1 -1
- data/spec/extensions/string_stripper_spec.rb +2 -1
- data/spec/extensions/to_dot_spec.rb +1 -1
- data/spec/extensions/typecast_on_load_spec.rb +3 -2
- data/spec/extensions/update_primary_key_spec.rb +2 -2
- data/spec/extensions/validation_class_methods_spec.rb +19 -19
- data/spec/extensions/validation_helpers_spec.rb +30 -21
- data/spec/extensions/xml_serializer_spec.rb +5 -5
- data/spec/integration/associations_test.rb +10 -30
- data/spec/integration/dataset_test.rb +20 -24
- data/spec/integration/eager_loader_test.rb +5 -5
- data/spec/integration/model_test.rb +3 -3
- data/spec/integration/plugin_test.rb +7 -39
- data/spec/integration/schema_test.rb +4 -38
- data/spec/integration/spec_helper.rb +2 -1
- data/spec/model/association_reflection_spec.rb +70 -5
- data/spec/model/associations_spec.rb +11 -11
- data/spec/model/base_spec.rb +25 -8
- data/spec/model/class_dataset_methods_spec.rb +143 -0
- data/spec/model/dataset_methods_spec.rb +1 -1
- data/spec/model/eager_loading_spec.rb +25 -25
- data/spec/model/hooks_spec.rb +1 -1
- data/spec/model/model_spec.rb +22 -7
- data/spec/model/plugins_spec.rb +1 -6
- data/spec/model/record_spec.rb +37 -29
- data/spec/model/spec_helper.rb +23 -1
- data/spec/model/validations_spec.rb +15 -17
- metadata +32 -3
data/spec/model/plugins_spec.rb
CHANGED
@@ -168,26 +168,22 @@ describe Sequel::Model, ".plugin" do
|
|
168
168
|
it "should extend the class's dataset with a DatasetMethods module if the plugin includes it" do
|
169
169
|
@c.plugin @t
|
170
170
|
@c.dataset.ghi.should == 345
|
171
|
-
@c.ghi.should == 345
|
172
171
|
end
|
173
172
|
|
174
173
|
it "should save the DatasetMethods module and apply it later if the class doesn't have a dataset" do
|
175
174
|
c = Class.new(Sequel::Model)
|
176
175
|
c.plugin @t
|
177
|
-
proc{c.ghi}.should raise_error(Sequel::Error)
|
178
176
|
c.dataset = MODEL_DB[:i]
|
179
177
|
c.dataset.ghi.should == 345
|
180
|
-
c.ghi.should == 345
|
181
178
|
end
|
182
179
|
|
183
180
|
it "should save the DatasetMethods module and apply it later if the class has a dataset" do
|
184
181
|
@c.plugin @t
|
185
182
|
@c.dataset = MODEL_DB[:i]
|
186
183
|
@c.dataset.ghi.should == 345
|
187
|
-
@c.ghi.should == 345
|
188
184
|
end
|
189
185
|
|
190
|
-
|
186
|
+
qspecify "should define class methods for all public instance methods in DatasetMethod" do
|
191
187
|
m = Module.new do
|
192
188
|
self::DatasetMethods = Module.new do
|
193
189
|
def a; 1; end
|
@@ -213,7 +209,6 @@ describe Sequel::Model, ".plugin" do
|
|
213
209
|
@c.dataset.b.should == 2
|
214
210
|
lambda{@c.dataset.a}.should raise_error(NoMethodError)
|
215
211
|
@c.dataset.send(:a).should == 1
|
216
|
-
@c.b.should == 2
|
217
212
|
lambda{@c.a}.should raise_error(NoMethodError)
|
218
213
|
lambda{@c.send(:a)}.should raise_error(NoMethodError)
|
219
214
|
end
|
data/spec/model/record_spec.rb
CHANGED
@@ -127,19 +127,25 @@ describe "Model#save" do
|
|
127
127
|
proc{o.save}.should_not raise_error
|
128
128
|
end
|
129
129
|
|
130
|
-
|
130
|
+
qspecify "should update only the given columns if given" do
|
131
131
|
o = @c.load(:id => 3, :x => 1, :y => nil)
|
132
132
|
o.save(:y)
|
133
133
|
MODEL_DB.sqls.first.should == "UPDATE items SET y = NULL WHERE (id = 3)"
|
134
134
|
end
|
135
135
|
|
136
|
+
it "should respect the :columns option to specify the columns to save" do
|
137
|
+
o = @c.load(:id => 3, :x => 1, :y => nil)
|
138
|
+
o.save(:columns=>:y)
|
139
|
+
MODEL_DB.sqls.first.should == "UPDATE items SET y = NULL WHERE (id = 3)"
|
140
|
+
end
|
141
|
+
|
136
142
|
it "should mark saved columns as not changed" do
|
137
143
|
o = @c.load(:id => 3, :x => 1, :y => nil)
|
138
144
|
o[:y] = 4
|
139
145
|
o.changed_columns.should == [:y]
|
140
|
-
o.save(:x)
|
146
|
+
o.save(:columns=>:x)
|
141
147
|
o.changed_columns.should == [:y]
|
142
|
-
o.save(:y)
|
148
|
+
o.save(:columns=>:y)
|
143
149
|
o.changed_columns.should == []
|
144
150
|
end
|
145
151
|
|
@@ -182,7 +188,7 @@ describe "Model#save" do
|
|
182
188
|
o = @c.load(:id => 23,:x => 2, :y => nil)
|
183
189
|
o[:x] = 2
|
184
190
|
o[:y] = 22
|
185
|
-
o.save(:x)
|
191
|
+
o.save(:columns=>:x)
|
186
192
|
res.should == [{:x=>2},nil]
|
187
193
|
o.after_save
|
188
194
|
res.should == [nil, nil]
|
@@ -190,19 +196,19 @@ describe "Model#save" do
|
|
190
196
|
|
191
197
|
it "should use Model's use_transactions setting by default" do
|
192
198
|
@c.use_transactions = true
|
193
|
-
@c.load(:id => 3, :x => 1, :y => nil).save(:y)
|
199
|
+
@c.load(:id => 3, :x => 1, :y => nil).save(:columns=>:y)
|
194
200
|
MODEL_DB.sqls.should == ["BEGIN", "UPDATE items SET y = NULL WHERE (id = 3)", "COMMIT"]
|
195
201
|
@c.use_transactions = false
|
196
|
-
@c.load(:id => 3, :x => 1, :y => nil).save(:y)
|
202
|
+
@c.load(:id => 3, :x => 1, :y => nil).save(:columns=>:y)
|
197
203
|
MODEL_DB.sqls.should == ["UPDATE items SET y = NULL WHERE (id = 3)"]
|
198
204
|
end
|
199
205
|
|
200
206
|
it "should inherit Model's use_transactions setting" do
|
201
207
|
@c.use_transactions = true
|
202
|
-
Class.new(@c).load(:id => 3, :x => 1, :y => nil).save(:y)
|
208
|
+
Class.new(@c).load(:id => 3, :x => 1, :y => nil).save(:columns=>:y)
|
203
209
|
MODEL_DB.sqls.should == ["BEGIN", "UPDATE items SET y = NULL WHERE (id = 3)", "COMMIT"]
|
204
210
|
@c.use_transactions = false
|
205
|
-
Class.new(@c).load(:id => 3, :x => 1, :y => nil).save(:y)
|
211
|
+
Class.new(@c).load(:id => 3, :x => 1, :y => nil).save(:columns=>:y)
|
206
212
|
MODEL_DB.sqls.should == ["UPDATE items SET y = NULL WHERE (id = 3)"]
|
207
213
|
end
|
208
214
|
|
@@ -210,23 +216,23 @@ describe "Model#save" do
|
|
210
216
|
o = @c.load(:id => 3, :x => 1, :y => nil)
|
211
217
|
o.use_transactions = false
|
212
218
|
@c.use_transactions = true
|
213
|
-
o.save(:y)
|
219
|
+
o.save(:columns=>:y)
|
214
220
|
MODEL_DB.sqls.should == ["UPDATE items SET y = NULL WHERE (id = 3)"]
|
215
221
|
o = @c.load(:id => 3, :x => 1, :y => nil)
|
216
222
|
o.use_transactions = true
|
217
223
|
@c.use_transactions = false
|
218
|
-
o.save(:y)
|
224
|
+
o.save(:columns=>:y)
|
219
225
|
MODEL_DB.sqls.should == ["BEGIN", "UPDATE items SET y = NULL WHERE (id = 3)", "COMMIT"]
|
220
226
|
end
|
221
227
|
|
222
228
|
it "should use :transaction option if given" do
|
223
229
|
o = @c.load(:id => 3, :x => 1, :y => nil)
|
224
230
|
o.use_transactions = true
|
225
|
-
o.save(:y, :transaction=>false)
|
231
|
+
o.save(:columns=>:y, :transaction=>false)
|
226
232
|
MODEL_DB.sqls.should == ["UPDATE items SET y = NULL WHERE (id = 3)"]
|
227
233
|
o = @c.load(:id => 3, :x => 1, :y => nil)
|
228
234
|
o.use_transactions = false
|
229
|
-
o.save(:y, :transaction=>true)
|
235
|
+
o.save(:columns=>:y, :transaction=>true)
|
230
236
|
MODEL_DB.sqls.should == ["BEGIN", "UPDATE items SET y = NULL WHERE (id = 3)", "COMMIT"]
|
231
237
|
end
|
232
238
|
|
@@ -237,7 +243,7 @@ describe "Model#save" do
|
|
237
243
|
def o.before_save
|
238
244
|
false
|
239
245
|
end
|
240
|
-
proc { o.save(:y) }.should raise_error(Sequel::BeforeHookFailed)
|
246
|
+
proc { o.save(:columns=>:y) }.should raise_error(Sequel::BeforeHookFailed)
|
241
247
|
MODEL_DB.sqls.should == ["BEGIN", "ROLLBACK"]
|
242
248
|
end
|
243
249
|
|
@@ -248,7 +254,7 @@ describe "Model#save" do
|
|
248
254
|
def o.before_save
|
249
255
|
false
|
250
256
|
end
|
251
|
-
proc { o.save(:y, :raise_on_failure => true) }.should raise_error(Sequel::BeforeHookFailed)
|
257
|
+
proc { o.save(:columns=>:y, :raise_on_failure => true) }.should raise_error(Sequel::BeforeHookFailed)
|
252
258
|
MODEL_DB.sqls.should == ["BEGIN", "ROLLBACK"]
|
253
259
|
end
|
254
260
|
|
@@ -260,7 +266,7 @@ describe "Model#save" do
|
|
260
266
|
false
|
261
267
|
end
|
262
268
|
MODEL_DB.transaction do
|
263
|
-
o.save(:y).should == nil
|
269
|
+
o.save(:columns=>:y).should == nil
|
264
270
|
MODEL_DB.run "BLAH"
|
265
271
|
end
|
266
272
|
MODEL_DB.sqls.should == ["BEGIN", "BLAH", "COMMIT"]
|
@@ -273,7 +279,7 @@ describe "Model#save" do
|
|
273
279
|
def o.before_save
|
274
280
|
false
|
275
281
|
end
|
276
|
-
o.save(:y).should == nil
|
282
|
+
o.save(:columns=>:y).should == nil
|
277
283
|
MODEL_DB.sqls.should == ["BEGIN", "ROLLBACK"]
|
278
284
|
end
|
279
285
|
|
@@ -283,7 +289,7 @@ describe "Model#save" do
|
|
283
289
|
def o.before_save
|
284
290
|
raise Sequel::Rollback
|
285
291
|
end
|
286
|
-
proc { o.save(:y) }.should raise_error(Sequel::Rollback)
|
292
|
+
proc { o.save(:columns=>:y) }.should raise_error(Sequel::Rollback)
|
287
293
|
MODEL_DB.sqls.should == []
|
288
294
|
end
|
289
295
|
|
@@ -674,7 +680,7 @@ describe Sequel::Model, "with a primary key" do
|
|
674
680
|
model_a.primary_key.should == :a
|
675
681
|
end
|
676
682
|
|
677
|
-
|
683
|
+
qspecify "should support multi argument composite keys" do
|
678
684
|
model_a = Class.new(Sequel::Model){ set_primary_key :a, :b }
|
679
685
|
model_a.primary_key.should == [:a, :b]
|
680
686
|
end
|
@@ -715,7 +721,7 @@ describe Sequel::Model, "#this" do
|
|
715
721
|
end
|
716
722
|
|
717
723
|
it "should support composite primary keys" do
|
718
|
-
@example.set_primary_key :x, :y
|
724
|
+
@example.set_primary_key [:x, :y]
|
719
725
|
instance = @example.load(:x => 4, :y => 5)
|
720
726
|
instance.this.sql.should =~ /SELECT \* FROM examples WHERE \(\([xy] = [45]\) AND \([xy] = [45]\)\) LIMIT 1/
|
721
727
|
end
|
@@ -858,7 +864,7 @@ describe Sequel::Model, "#set" do
|
|
858
864
|
|
859
865
|
it "should raise error if strict_param_setting is true and column is restricted" do
|
860
866
|
@o1.strict_param_setting = true
|
861
|
-
@c.
|
867
|
+
@c.set_allowed_columns
|
862
868
|
proc{@o1.set('x' => 1)}.should raise_error(Sequel::Error)
|
863
869
|
end
|
864
870
|
|
@@ -1087,7 +1093,6 @@ describe Sequel::Model, "#(set|update)_(all|except|only)" do
|
|
1087
1093
|
set_primary_key :id
|
1088
1094
|
columns :x, :y, :z, :id
|
1089
1095
|
set_allowed_columns :x
|
1090
|
-
set_restricted_columns :y
|
1091
1096
|
end
|
1092
1097
|
@c.strict_param_setting = false
|
1093
1098
|
@o1 = @c.new
|
@@ -1105,7 +1110,10 @@ describe Sequel::Model, "#(set|update)_(all|except|only)" do
|
|
1105
1110
|
proc{@c.new.set_only({:x => 1, :y => 2, :z=>3}, :x, :y)}.should raise_error(Sequel::Error)
|
1106
1111
|
(o = @c.new).set_only({:x => 1, :y => 2}, :x, :y)
|
1107
1112
|
o.values.should == {:x => 1, :y => 2}
|
1113
|
+
end
|
1108
1114
|
|
1115
|
+
qspecify "should raise errors for set_except if not all hash fields can be set and strict_param_setting is true" do
|
1116
|
+
@c.strict_param_setting = true
|
1109
1117
|
proc{@c.new.set_except({:x => 1, :y => 2, :z=>3, :id=>4}, :x, :y)}.should raise_error(Sequel::Error)
|
1110
1118
|
proc{@c.new.set_except({:x => 1, :y => 2, :z=>3}, :x, :y)}.should raise_error(Sequel::Error)
|
1111
1119
|
(o = @c.new).set_except({:z => 3}, :x, :y)
|
@@ -1126,7 +1134,7 @@ describe Sequel::Model, "#(set|update)_(all|except|only)" do
|
|
1126
1134
|
@o1.values.should == {:x => 9, :y => 8, :id=>7}
|
1127
1135
|
end
|
1128
1136
|
|
1129
|
-
|
1137
|
+
qspecify "#set_except should not set given attributes or the primary key" do
|
1130
1138
|
@o1.set_except({:x => 1, :y => 2, :z=>3, :id=>4}, [:y, :z])
|
1131
1139
|
@o1.values.should == {:x => 1}
|
1132
1140
|
@o1.set_except({:x => 4, :y => 2, :z=>3, :id=>4}, :y, :z)
|
@@ -1149,7 +1157,7 @@ describe Sequel::Model, "#(set|update)_(all|except|only)" do
|
|
1149
1157
|
MODEL_DB.sqls.should == ["INSERT INTO items (x) VALUES (1)", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
|
1150
1158
|
end
|
1151
1159
|
|
1152
|
-
|
1160
|
+
qspecify "#update_except should not update given attributes" do
|
1153
1161
|
@o1.update_except({:x => 1, :y => 2, :z=>3, :id=>4}, [:y, :z])
|
1154
1162
|
MODEL_DB.sqls.should == ["INSERT INTO items (x) VALUES (1)", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
|
1155
1163
|
@c.new.update_except({:x => 1, :y => 2, :z=>3, :id=>4}, :y, :z)
|
@@ -1255,12 +1263,12 @@ describe Sequel::Model, "#exists?" do
|
|
1255
1263
|
|
1256
1264
|
it "should do a query to check if the record exists" do
|
1257
1265
|
@model.load(:id=>1).exists?.should be_true
|
1258
|
-
MODEL_DB.sqls.should == ['SELECT 1 FROM items WHERE (id = 1) LIMIT 1']
|
1266
|
+
MODEL_DB.sqls.should == ['SELECT 1 AS one FROM items WHERE (id = 1) LIMIT 1']
|
1259
1267
|
end
|
1260
1268
|
|
1261
1269
|
it "should return false when #this.count == 0" do
|
1262
1270
|
@model.load(:id=>2).exists?.should be_false
|
1263
|
-
MODEL_DB.sqls.should == ['SELECT 1 FROM items WHERE (id = 2) LIMIT 1']
|
1271
|
+
MODEL_DB.sqls.should == ['SELECT 1 AS one FROM items WHERE (id = 2) LIMIT 1']
|
1264
1272
|
end
|
1265
1273
|
|
1266
1274
|
it "should return false without issuing a query if the model object is new" do
|
@@ -1382,10 +1390,10 @@ describe Sequel::Model, "#hash" do
|
|
1382
1390
|
specify "should be the same only for objects with the same class and pk if pk is composite and all values are non-NULL" do
|
1383
1391
|
z = Class.new(Sequel::Model)
|
1384
1392
|
z.columns :id, :id2, :x
|
1385
|
-
z.set_primary_key(:id, :id2)
|
1393
|
+
z.set_primary_key([:id, :id2])
|
1386
1394
|
y = Class.new(Sequel::Model)
|
1387
1395
|
y.columns :id, :id2, :x
|
1388
|
-
y.set_primary_key(:id, :id2)
|
1396
|
+
y.set_primary_key([:id, :id2])
|
1389
1397
|
a = z.load(:id => 1, :id2=>2, :x => 3)
|
1390
1398
|
|
1391
1399
|
a.hash.should == z.load(:id => 1, :id2=>2, :x => 4).hash
|
@@ -1396,10 +1404,10 @@ describe Sequel::Model, "#hash" do
|
|
1396
1404
|
specify "should be the same only for objects with the same class and value if pk is composite and one values is NULL" do
|
1397
1405
|
z = Class.new(Sequel::Model)
|
1398
1406
|
z.columns :id, :id2, :x
|
1399
|
-
z.set_primary_key(:id, :id2)
|
1407
|
+
z.set_primary_key([:id, :id2])
|
1400
1408
|
y = Class.new(Sequel::Model)
|
1401
1409
|
y.columns :id, :id2, :x
|
1402
|
-
y.set_primary_key(:id, :id2)
|
1410
|
+
y.set_primary_key([:id, :id2])
|
1403
1411
|
|
1404
1412
|
a = z.load(:id => 1, :id2 => nil, :x => 3)
|
1405
1413
|
a.hash.should == z.load(:id => 1, :id2=>nil, :x => 3).hash
|
data/spec/model/spec_helper.rb
CHANGED
@@ -3,12 +3,33 @@ unless Object.const_defined?('Sequel') && Sequel.const_defined?('Model')
|
|
3
3
|
$:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../../lib/"))
|
4
4
|
require 'sequel/no_core_ext'
|
5
5
|
end
|
6
|
+
Sequel::Deprecation.backtrace_filter = lambda{|line, lineno| lineno < 4 || line =~ /_spec\.rb/}
|
6
7
|
|
7
8
|
if ENV['SEQUEL_COLUMNS_INTROSPECTION']
|
8
9
|
Sequel.extension :columns_introspection
|
9
10
|
Sequel::Dataset.introspect_all_columns
|
10
11
|
end
|
11
12
|
|
13
|
+
(defined?(RSpec) ? RSpec::Core::ExampleGroup : Spec::Example::ExampleGroup).class_eval do
|
14
|
+
if ENV['SEQUEL_DEPRECATION_WARNINGS']
|
15
|
+
class << self
|
16
|
+
alias qspecify specify
|
17
|
+
end
|
18
|
+
else
|
19
|
+
def self.qspecify(*a, &block)
|
20
|
+
specify(*a) do
|
21
|
+
begin
|
22
|
+
output = Sequel::Deprecation.output
|
23
|
+
Sequel::Deprecation.output = false
|
24
|
+
instance_exec(&block)
|
25
|
+
ensure
|
26
|
+
Sequel::Deprecation.output = output
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
12
33
|
Sequel.quote_identifiers = false
|
13
34
|
Sequel.identifier_input_method = nil
|
14
35
|
Sequel.identifier_output_method = nil
|
@@ -28,9 +49,10 @@ class << Sequel::Model
|
|
28
49
|
end
|
29
50
|
|
30
51
|
Sequel::Model.use_transactions = false
|
31
|
-
Sequel
|
52
|
+
Sequel.cache_anonymous_models = false
|
32
53
|
|
33
54
|
db = Sequel.mock(:fetch=>{:id => 1, :x => 1}, :numrows=>1, :autoid=>proc{|sql| 10})
|
34
55
|
def db.schema(*) [[:id, {:primary_key=>true}]] end
|
35
56
|
def db.reset() sqls end
|
57
|
+
def db.supports_schema_parsing?() true end
|
36
58
|
Sequel::Model.db = MODEL_DB = db
|
@@ -14,16 +14,14 @@ describe Sequel::Model::Errors do
|
|
14
14
|
|
15
15
|
specify "should be empty if there are no errors" do
|
16
16
|
@errors.should be_empty
|
17
|
-
@errors[:blah]
|
18
|
-
@errors.should be_empty
|
19
17
|
end
|
20
18
|
|
21
19
|
specify "should not be empty if there are errors" do
|
22
|
-
@errors
|
20
|
+
@errors.add(:blah, "blah")
|
23
21
|
@errors.should_not be_empty
|
24
22
|
end
|
25
23
|
|
26
|
-
|
24
|
+
qspecify "should return errors for a specific attribute using #[]" do
|
27
25
|
@errors[:blah].should == []
|
28
26
|
@errors[:blah] << 'blah'
|
29
27
|
@errors[:blah].should == ['blah']
|
@@ -32,30 +30,30 @@ describe Sequel::Model::Errors do
|
|
32
30
|
end
|
33
31
|
|
34
32
|
specify "should return an array of errors for a specific attribute using #on if there are errors" do
|
35
|
-
@errors
|
33
|
+
@errors.add(:blah, 'blah')
|
36
34
|
@errors.on(:blah).should == ['blah']
|
37
35
|
end
|
38
36
|
|
39
37
|
specify "should return nil using #on if there are no errors for that attribute" do
|
40
38
|
@errors.on(:blah).should == nil
|
41
|
-
@errors[:blah]
|
42
|
-
@errors.on(:blah).should == nil
|
43
39
|
end
|
44
40
|
|
45
|
-
|
41
|
+
qspecify "should accept errors using #[] <<" do
|
46
42
|
@errors[:blah] << 'blah'
|
47
43
|
@errors[:blah].should == ['blah']
|
44
|
+
end
|
48
45
|
|
46
|
+
specify "should accept errors using #add" do
|
49
47
|
@errors.add :blah, 'zzzz'
|
50
|
-
@errors[:blah].should == ['
|
48
|
+
@errors[:blah].should == ['zzzz']
|
51
49
|
end
|
52
50
|
|
53
51
|
specify "should return full messages using #full_messages" do
|
54
52
|
@errors.full_messages.should == []
|
55
53
|
|
56
|
-
@errors
|
57
|
-
@errors
|
58
|
-
@errors
|
54
|
+
@errors.add(:blow, 'blieuh')
|
55
|
+
@errors.add(:blow, 'blich')
|
56
|
+
@errors.add(:blay, 'bliu')
|
59
57
|
msgs = @errors.full_messages
|
60
58
|
msgs.size.should == 3
|
61
59
|
msgs.should include('blow blieuh', 'blow blich', 'blay bliu')
|
@@ -64,9 +62,9 @@ describe Sequel::Model::Errors do
|
|
64
62
|
specify "should not add column names for LiteralStrings" do
|
65
63
|
@errors.full_messages.should == []
|
66
64
|
|
67
|
-
@errors
|
68
|
-
@errors
|
69
|
-
@errors
|
65
|
+
@errors.add(:blow, 'blieuh')
|
66
|
+
@errors.add(:blow, Sequel.lit('blich'))
|
67
|
+
@errors.add(:blay, 'bliu')
|
70
68
|
msgs = @errors.full_messages
|
71
69
|
msgs.size.should == 3
|
72
70
|
msgs.should include('blow blieuh', 'blich', 'blay bliu')
|
@@ -103,7 +101,7 @@ describe Sequel::Model do
|
|
103
101
|
@c = Class.new(Sequel::Model) do
|
104
102
|
columns :score
|
105
103
|
def validate
|
106
|
-
errors
|
104
|
+
errors.add(:score, 'too low') if score < 87
|
107
105
|
end
|
108
106
|
end
|
109
107
|
|
@@ -125,7 +123,7 @@ describe Sequel::Model do
|
|
125
123
|
@o.score = 86
|
126
124
|
@o.should_not be_valid
|
127
125
|
@o.errors[:score].should == ['too low']
|
128
|
-
@o.errors
|
126
|
+
@o.errors.on(:blah).should be_nil
|
129
127
|
end
|
130
128
|
|
131
129
|
specify "should allow raising of ValidationFailed with a Model instance with errors" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.48.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: The Database Toolkit for Ruby
|
14
14
|
email: code@jeremyevans.net
|
@@ -45,6 +45,7 @@ extra_rdoc_files:
|
|
45
45
|
- doc/bin_sequel.rdoc
|
46
46
|
- doc/security.rdoc
|
47
47
|
- doc/postgresql.rdoc
|
48
|
+
- doc/code_order.rdoc
|
48
49
|
- doc/release_notes/1.0.txt
|
49
50
|
- doc/release_notes/1.1.txt
|
50
51
|
- doc/release_notes/1.3.txt
|
@@ -111,6 +112,7 @@ extra_rdoc_files:
|
|
111
112
|
- doc/release_notes/3.45.0.txt
|
112
113
|
- doc/release_notes/3.46.0.txt
|
113
114
|
- doc/release_notes/3.47.0.txt
|
115
|
+
- doc/release_notes/3.48.0.txt
|
114
116
|
files:
|
115
117
|
- MIT-LICENSE
|
116
118
|
- CHANGELOG
|
@@ -195,6 +197,7 @@ files:
|
|
195
197
|
- doc/release_notes/3.45.0.txt
|
196
198
|
- doc/release_notes/3.46.0.txt
|
197
199
|
- doc/release_notes/3.47.0.txt
|
200
|
+
- doc/release_notes/3.48.0.txt
|
198
201
|
- doc/sharding.rdoc
|
199
202
|
- doc/sql.rdoc
|
200
203
|
- doc/validations.rdoc
|
@@ -209,6 +212,7 @@ files:
|
|
209
212
|
- doc/bin_sequel.rdoc
|
210
213
|
- doc/security.rdoc
|
211
214
|
- doc/postgresql.rdoc
|
215
|
+
- doc/code_order.rdoc
|
212
216
|
- spec/adapters/firebird_spec.rb
|
213
217
|
- spec/adapters/informix_spec.rb
|
214
218
|
- spec/adapters/mssql_spec.rb
|
@@ -226,6 +230,7 @@ files:
|
|
226
230
|
- spec/core/object_graph_spec.rb
|
227
231
|
- spec/core/schema_generator_spec.rb
|
228
232
|
- spec/core/spec_helper.rb
|
233
|
+
- spec/core/deprecated_spec.rb
|
229
234
|
- spec/core/version_spec.rb
|
230
235
|
- spec/core/mock_adapter_spec.rb
|
231
236
|
- spec/extensions/active_model_spec.rb
|
@@ -324,6 +329,15 @@ files:
|
|
324
329
|
- spec/extensions/unlimited_update_spec.rb
|
325
330
|
- spec/extensions/error_splitter_spec.rb
|
326
331
|
- spec/extensions/input_transformer_spec.rb
|
332
|
+
- spec/extensions/filter_having_spec.rb
|
333
|
+
- spec/extensions/hash_aliases_spec.rb
|
334
|
+
- spec/extensions/after_initialize_spec.rb
|
335
|
+
- spec/extensions/set_overrides_spec.rb
|
336
|
+
- spec/extensions/graph_each_spec.rb
|
337
|
+
- spec/extensions/blacklist_security_spec.rb
|
338
|
+
- spec/extensions/sequel_3_dataset_methods_spec.rb
|
339
|
+
- spec/extensions/empty_array_ignore_nulls_spec.rb
|
340
|
+
- spec/extensions/scissors_spec.rb
|
327
341
|
- spec/integration/associations_test.rb
|
328
342
|
- spec/integration/database_test.rb
|
329
343
|
- spec/integration/dataset_test.rb
|
@@ -349,6 +363,7 @@ files:
|
|
349
363
|
- spec/model/record_spec.rb
|
350
364
|
- spec/model/spec_helper.rb
|
351
365
|
- spec/model/validations_spec.rb
|
366
|
+
- spec/model/class_dataset_methods_spec.rb
|
352
367
|
- spec/rcov.opts
|
353
368
|
- spec/spec_config.rb.example
|
354
369
|
- spec/spec_config.rb
|
@@ -398,6 +413,7 @@ files:
|
|
398
413
|
- spec/files/transaction_unspecified_migrations/002_create_basic.rb
|
399
414
|
- spec/core_extensions_spec.rb
|
400
415
|
- spec/sequel_coverage.rb
|
416
|
+
- spec/bin_spec.rb
|
401
417
|
- lib/sequel.rb
|
402
418
|
- lib/sequel/adapters/ado.rb
|
403
419
|
- lib/sequel/adapters/ado/mssql.rb
|
@@ -452,6 +468,7 @@ files:
|
|
452
468
|
- lib/sequel/adapters/utils/emulate_offset_with_row_number.rb
|
453
469
|
- lib/sequel/adapters/utils/pg_types.rb
|
454
470
|
- lib/sequel/adapters/utils/split_alter_table.rb
|
471
|
+
- lib/sequel/adapters/utils/emulate_offset_with_reverse_and_count.rb
|
455
472
|
- lib/sequel/adapters/mysql2.rb
|
456
473
|
- lib/sequel/adapters/swift.rb
|
457
474
|
- lib/sequel/adapters/swift/mysql.rb
|
@@ -531,6 +548,13 @@ files:
|
|
531
548
|
- lib/sequel/extensions/date_arithmetic.rb
|
532
549
|
- lib/sequel/extensions/core_refinements.rb
|
533
550
|
- lib/sequel/extensions/meta_def.rb
|
551
|
+
- lib/sequel/extensions/filter_having.rb
|
552
|
+
- lib/sequel/extensions/hash_aliases.rb
|
553
|
+
- lib/sequel/extensions/ruby18_symbol_extensions.rb
|
554
|
+
- lib/sequel/extensions/set_overrides.rb
|
555
|
+
- lib/sequel/extensions/graph_each.rb
|
556
|
+
- lib/sequel/extensions/sequel_3_dataset_methods.rb
|
557
|
+
- lib/sequel/extensions/empty_array_ignore_nulls.rb
|
534
558
|
- lib/sequel/version.rb
|
535
559
|
- lib/sequel/model.rb
|
536
560
|
- lib/sequel/model/associations.rb
|
@@ -595,10 +619,15 @@ files:
|
|
595
619
|
- lib/sequel/plugins/unlimited_update.rb
|
596
620
|
- lib/sequel/plugins/auto_validations.rb
|
597
621
|
- lib/sequel/plugins/error_splitter.rb
|
622
|
+
- lib/sequel/plugins/scissors.rb
|
598
623
|
- lib/sequel/plugins/input_transformer.rb
|
624
|
+
- lib/sequel/plugins/after_initialize.rb
|
625
|
+
- lib/sequel/plugins/blacklist_security.rb
|
599
626
|
- lib/sequel/timezones.rb
|
627
|
+
- lib/sequel/deprecated.rb
|
600
628
|
- lib/sequel/ast_transformer.rb
|
601
629
|
- lib/sequel/no_core_ext.rb
|
630
|
+
- lib/sequel/deprecated_core_extensions.rb
|
602
631
|
- lib/sequel_core.rb
|
603
632
|
- lib/sequel_model.rb
|
604
633
|
homepage: http://sequel.rubyforge.org
|
@@ -627,7 +656,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
627
656
|
version: '0'
|
628
657
|
requirements: []
|
629
658
|
rubyforge_project: sequel
|
630
|
-
rubygems_version: 2.0.
|
659
|
+
rubygems_version: 2.0.2
|
631
660
|
signing_key:
|
632
661
|
specification_version: 4
|
633
662
|
summary: The Database Toolkit for Ruby
|