sequel 3.42.0 → 3.43.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +40 -0
- data/MIT-LICENSE +1 -1
- data/Rakefile +1 -1
- data/doc/opening_databases.rdoc +2 -2
- data/doc/prepared_statements.rdoc +7 -0
- data/doc/release_notes/3.43.0.txt +105 -0
- data/doc/schema_modification.rdoc +19 -0
- data/lib/sequel/adapters/do/mysql.rb +1 -1
- data/lib/sequel/adapters/jdbc.rb +13 -8
- data/lib/sequel/adapters/jdbc/hsqldb.rb +5 -0
- data/lib/sequel/adapters/jdbc/mysql.rb +1 -1
- data/lib/sequel/adapters/jdbc/oracle.rb +6 -0
- data/lib/sequel/adapters/jdbc/postgresql.rb +9 -3
- data/lib/sequel/adapters/mysql.rb +1 -1
- data/lib/sequel/adapters/mysql2.rb +1 -1
- data/lib/sequel/adapters/oracle.rb +1 -1
- data/lib/sequel/adapters/postgres.rb +4 -2
- data/lib/sequel/adapters/shared/db2.rb +12 -0
- data/lib/sequel/adapters/shared/mssql.rb +9 -5
- data/lib/sequel/adapters/shared/postgres.rb +2 -0
- data/lib/sequel/adapters/swift/mysql.rb +1 -1
- data/lib/sequel/core.rb +2 -2
- data/lib/sequel/database.rb +0 -2
- data/lib/sequel/database/query.rb +20 -5
- data/lib/sequel/database/schema_generator.rb +5 -0
- data/lib/sequel/database/schema_methods.rb +5 -0
- data/lib/sequel/dataset.rb +0 -2
- data/lib/sequel/dataset/actions.rb +25 -2
- data/lib/sequel/dataset/misc.rb +1 -1
- data/lib/sequel/dataset/sql.rb +28 -6
- data/lib/sequel/extensions/core_refinements.rb +221 -0
- data/lib/sequel/extensions/date_arithmetic.rb +194 -0
- data/lib/sequel/extensions/meta_def.rb +30 -0
- data/lib/sequel/extensions/migration.rb +5 -0
- data/lib/sequel/extensions/null_dataset.rb +2 -0
- data/lib/sequel/extensions/pagination.rb +2 -0
- data/lib/sequel/extensions/pg_array.rb +12 -1
- data/lib/sequel/extensions/pg_array_ops.rb +10 -1
- data/lib/sequel/extensions/pg_hstore.rb +12 -1
- data/lib/sequel/extensions/pg_hstore_ops.rb +10 -1
- data/lib/sequel/extensions/pg_json.rb +18 -1
- data/lib/sequel/extensions/pg_range.rb +12 -1
- data/lib/sequel/extensions/pg_range_ops.rb +10 -1
- data/lib/sequel/extensions/pg_row.rb +18 -2
- data/lib/sequel/extensions/pg_row_ops.rb +10 -1
- data/lib/sequel/extensions/query.rb +2 -0
- data/lib/sequel/model/associations.rb +5 -13
- data/lib/sequel/model/base.rb +4 -6
- data/lib/sequel/plugins/boolean_readers.rb +4 -2
- data/lib/sequel/plugins/many_through_many.rb +23 -0
- data/lib/sequel/plugins/string_stripper.rb +53 -3
- data/lib/sequel/plugins/validation_class_methods.rb +5 -0
- data/lib/sequel/sql.rb +3 -3
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/db2_spec.rb +19 -8
- data/spec/adapters/mssql_spec.rb +1 -2
- data/spec/adapters/mysql_spec.rb +2 -2
- data/spec/adapters/postgres_spec.rb +29 -3
- data/spec/core/dataset_spec.rb +107 -0
- data/spec/core/expression_filters_spec.rb +5 -0
- data/spec/core/schema_spec.rb +14 -3
- data/spec/core/spec_helper.rb +2 -0
- data/spec/extensions/core_refinements_spec.rb +551 -0
- data/spec/extensions/date_arithmetic_spec.rb +150 -0
- data/spec/extensions/force_encoding_spec.rb +1 -1
- data/spec/extensions/meta_def_spec.rb +21 -0
- data/spec/extensions/spec_helper.rb +5 -0
- data/spec/extensions/string_stripper_spec.rb +44 -2
- data/spec/integration/associations_test.rb +2 -2
- data/spec/integration/plugin_test.rb +90 -0
- data/spec/integration/schema_test.rb +1 -1
- data/spec/model/association_reflection_spec.rb +4 -4
- data/spec/model/associations_spec.rb +2 -2
- data/spec/model/base_spec.rb +2 -2
- data/spec/model/eager_loading_spec.rb +5 -5
- data/spec/model/hooks_spec.rb +4 -4
- data/spec/model/model_spec.rb +9 -9
- data/spec/model/record_spec.rb +15 -18
- metadata +12 -5
- data/lib/sequel/metaprogramming.rb +0 -13
data/spec/model/hooks_spec.rb
CHANGED
@@ -385,19 +385,19 @@ describe "Model around filters" do
|
|
385
385
|
@c.raise_on_save_failure = false
|
386
386
|
|
387
387
|
o = @c.load(:id => 1)
|
388
|
-
o.
|
388
|
+
def o.around_save() end
|
389
389
|
o.save.should == nil
|
390
390
|
|
391
391
|
o = @c.load(:id => 1)
|
392
|
-
o.
|
392
|
+
def o.around_update() end
|
393
393
|
o.save.should == nil
|
394
394
|
|
395
395
|
o = @c.new
|
396
|
-
o.
|
396
|
+
def o.around_create() end
|
397
397
|
o.save.should == nil
|
398
398
|
|
399
399
|
o = @c.new
|
400
|
-
o.
|
400
|
+
def o.around_validation() end
|
401
401
|
o.save.should == nil
|
402
402
|
end
|
403
403
|
end
|
data/spec/model/model_spec.rb
CHANGED
@@ -248,22 +248,22 @@ describe Sequel::Model, "dataset & schema" do
|
|
248
248
|
end
|
249
249
|
|
250
250
|
it "should raise an error on set_dataset if there is an error connecting to the database" do
|
251
|
-
@model.
|
251
|
+
def @model.columns() raise Sequel::DatabaseConnectionError end
|
252
252
|
proc{@model.set_dataset(Sequel::Database.new[:foo].join(:blah))}.should raise_error
|
253
253
|
end
|
254
254
|
|
255
255
|
it "should not raise an error if there is a problem getting the columns for a dataset" do
|
256
|
-
@model.
|
256
|
+
def @model.columns() raise Sequel::Error end
|
257
257
|
proc{@model.set_dataset(MODEL_DB[:foo].join(:blah))}.should_not raise_error
|
258
258
|
end
|
259
259
|
|
260
260
|
it "doesn't raise an error on set_dataset if there is an error raised getting the schema" do
|
261
|
-
@model.
|
261
|
+
def @model.get_db_schema(*) raise Sequel::Error end
|
262
262
|
proc{@model.set_dataset(MODEL_DB[:foo])}.should_not raise_error
|
263
263
|
end
|
264
264
|
|
265
265
|
it "doesn't raise an error on inherited if there is an error setting the dataset" do
|
266
|
-
@model.
|
266
|
+
def @model.set_dataset(*) raise Sequel::Error end
|
267
267
|
proc{Class.new(@model)}.should_not raise_error
|
268
268
|
end
|
269
269
|
end
|
@@ -376,7 +376,7 @@ describe Sequel::Model, ".subset" do
|
|
376
376
|
end
|
377
377
|
|
378
378
|
specify "should not override existing model methods" do
|
379
|
-
@c.
|
379
|
+
def @c.active() true end
|
380
380
|
@c.subset(:active, :active)
|
381
381
|
@c.active.should == true
|
382
382
|
end
|
@@ -652,7 +652,7 @@ describe "Model.db_schema" do
|
|
652
652
|
specify "should automatically set a singular primary key based on the schema" do
|
653
653
|
ds = @dataset
|
654
654
|
d = ds.db
|
655
|
-
d.
|
655
|
+
def d.schema(table, *opts) [[:x, {:primary_key=>true}]] end
|
656
656
|
@c.primary_key.should == :id
|
657
657
|
@c.dataset = ds
|
658
658
|
@c.db_schema.should == {:x=>{:primary_key=>true}}
|
@@ -662,7 +662,7 @@ describe "Model.db_schema" do
|
|
662
662
|
specify "should automatically set the composite primary key based on the schema" do
|
663
663
|
ds = @dataset
|
664
664
|
d = ds.db
|
665
|
-
d.
|
665
|
+
def d.schema(table, *opts) [[:x, {:primary_key=>true}], [:y, {:primary_key=>true}]] end
|
666
666
|
@c.primary_key.should == :id
|
667
667
|
@c.dataset = ds
|
668
668
|
@c.db_schema.should == {:x=>{:primary_key=>true}, :y=>{:primary_key=>true}}
|
@@ -672,7 +672,7 @@ describe "Model.db_schema" do
|
|
672
672
|
specify "should automatically set no primary key based on the schema" do
|
673
673
|
ds = @dataset
|
674
674
|
d = ds.db
|
675
|
-
d.
|
675
|
+
def d.schema(table, *opts) [[:x, {:primary_key=>false}], [:y, {:primary_key=>false}]] end
|
676
676
|
@c.primary_key.should == :id
|
677
677
|
@c.dataset = ds
|
678
678
|
@c.db_schema.should == {:x=>{:primary_key=>false}, :y=>{:primary_key=>false}}
|
@@ -682,7 +682,7 @@ describe "Model.db_schema" do
|
|
682
682
|
specify "should not modify the primary key unless all column schema hashes have a :primary_key entry" do
|
683
683
|
ds = @dataset
|
684
684
|
d = ds.db
|
685
|
-
d.
|
685
|
+
def d.schema(table, *opts) [[:x, {:primary_key=>false}], [:y, {}]] end
|
686
686
|
@c.primary_key.should == :id
|
687
687
|
@c.dataset = ds
|
688
688
|
@c.db_schema.should == {:x=>{:primary_key=>false}, :y=>{}}
|
data/spec/model/record_spec.rb
CHANGED
@@ -96,7 +96,7 @@ describe "Model#save" do
|
|
96
96
|
@c.unrestrict_primary_key
|
97
97
|
@c.set_primary_key [:x, :y]
|
98
98
|
o = @c.new(:x => 11)
|
99
|
-
o.
|
99
|
+
def o.autoincrementing_primary_key() :y end
|
100
100
|
o.save
|
101
101
|
sqls = MODEL_DB.sqls
|
102
102
|
sqls.length.should == 2
|
@@ -152,7 +152,7 @@ describe "Model#save" do
|
|
152
152
|
end
|
153
153
|
|
154
154
|
it "should mark all columns as not changed if this is a new record and insert_select was used" do
|
155
|
-
@c.dataset.
|
155
|
+
def (@c.dataset).insert_select(h) h.merge(:id=>1) end
|
156
156
|
o = @c.new(:x => 1, :y => nil)
|
157
157
|
o.x = 4
|
158
158
|
o.changed_columns.should == [:x]
|
@@ -1088,17 +1088,17 @@ describe Sequel::Model, "#destroy with filtered dataset" do
|
|
1088
1088
|
end
|
1089
1089
|
|
1090
1090
|
it "should raise a NoExistingObject exception if the dataset delete call doesn't return 1" do
|
1091
|
-
@instance.this.
|
1091
|
+
def (@instance.this).execute_dui(*a) 0 end
|
1092
1092
|
proc{@instance.delete}.should raise_error(Sequel::NoExistingObject)
|
1093
|
-
@instance.this.
|
1093
|
+
def (@instance.this).execute_dui(*a) 2 end
|
1094
1094
|
proc{@instance.delete}.should raise_error(Sequel::NoExistingObject)
|
1095
|
-
@instance.this.
|
1095
|
+
def (@instance.this).execute_dui(*a) 1 end
|
1096
1096
|
proc{@instance.delete}.should_not raise_error
|
1097
1097
|
|
1098
1098
|
@instance.require_modification = false
|
1099
|
-
@instance.this.
|
1099
|
+
def (@instance.this).execute_dui(*a) 0 end
|
1100
1100
|
proc{@instance.delete}.should_not raise_error
|
1101
|
-
@instance.this.
|
1101
|
+
def (@instance.this).execute_dui(*a) 2 end
|
1102
1102
|
proc{@instance.delete}.should_not raise_error
|
1103
1103
|
end
|
1104
1104
|
|
@@ -1122,17 +1122,17 @@ describe Sequel::Model, "#destroy" do
|
|
1122
1122
|
end
|
1123
1123
|
|
1124
1124
|
it "should raise a NoExistingObject exception if the dataset delete call doesn't return 1" do
|
1125
|
-
@model.dataset.
|
1125
|
+
def (@model.dataset).execute_dui(*a) 0 end
|
1126
1126
|
proc{@instance.delete}.should raise_error(Sequel::NoExistingObject)
|
1127
|
-
@model.dataset.
|
1127
|
+
def (@model.dataset).execute_dui(*a) 2 end
|
1128
1128
|
proc{@instance.delete}.should raise_error(Sequel::NoExistingObject)
|
1129
|
-
@model.dataset.
|
1129
|
+
def (@model.dataset).execute_dui(*a) 1 end
|
1130
1130
|
proc{@instance.delete}.should_not raise_error
|
1131
1131
|
|
1132
1132
|
@instance.require_modification = false
|
1133
|
-
@model.dataset.
|
1133
|
+
def (@model.dataset).execute_dui(*a) 0 end
|
1134
1134
|
proc{@instance.delete}.should_not raise_error
|
1135
|
-
@model.dataset.
|
1135
|
+
def (@model.dataset).execute_dui(*a) 2 end
|
1136
1136
|
proc{@instance.delete}.should_not raise_error
|
1137
1137
|
end
|
1138
1138
|
|
@@ -1868,21 +1868,18 @@ describe "Model#lock!" do
|
|
1868
1868
|
|
1869
1869
|
it "should do nothing if the record is a new record" do
|
1870
1870
|
o = @c.new
|
1871
|
-
|
1872
|
-
o.meta_def(:_refresh){|x| called = true; super(x)}
|
1871
|
+
def o._refresh(x) raise Sequel::Error; super(x) end
|
1873
1872
|
x = o.lock!
|
1874
1873
|
x.should == o
|
1875
|
-
called.should == false
|
1876
1874
|
MODEL_DB.sqls.should == []
|
1877
1875
|
end
|
1878
1876
|
|
1879
1877
|
it "should refresh the record using for_update if it is not a new record" do
|
1880
1878
|
o = @c.load(:id => 1)
|
1881
|
-
|
1882
|
-
o.meta_def(:_refresh){|x| called = true; super(x)}
|
1879
|
+
def o._refresh(x) instance_variable_set(:@a, 1); super(x) end
|
1883
1880
|
x = o.lock!
|
1884
1881
|
x.should == o
|
1885
|
-
|
1882
|
+
o.instance_variable_get(:@a).should == 1
|
1886
1883
|
MODEL_DB.sqls.should == ["SELECT * FROM items WHERE (id = 1) LIMIT 1 FOR UPDATE"]
|
1887
1884
|
end
|
1888
1885
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.43.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-08 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: The Database Toolkit for Ruby
|
15
15
|
email: code@jeremyevans.net
|
@@ -105,6 +105,7 @@ extra_rdoc_files:
|
|
105
105
|
- doc/release_notes/3.40.0.txt
|
106
106
|
- doc/release_notes/3.41.0.txt
|
107
107
|
- doc/release_notes/3.42.0.txt
|
108
|
+
- doc/release_notes/3.43.0.txt
|
108
109
|
files:
|
109
110
|
- MIT-LICENSE
|
110
111
|
- CHANGELOG
|
@@ -184,6 +185,7 @@ files:
|
|
184
185
|
- doc/release_notes/3.40.0.txt
|
185
186
|
- doc/release_notes/3.41.0.txt
|
186
187
|
- doc/release_notes/3.42.0.txt
|
188
|
+
- doc/release_notes/3.43.0.txt
|
187
189
|
- doc/sharding.rdoc
|
188
190
|
- doc/sql.rdoc
|
189
191
|
- doc/validations.rdoc
|
@@ -250,12 +252,13 @@ files:
|
|
250
252
|
- spec/extensions/timestamps_spec.rb
|
251
253
|
- spec/extensions/typecast_on_load_spec.rb
|
252
254
|
- spec/extensions/validation_helpers_spec.rb
|
255
|
+
- spec/extensions/string_stripper_spec.rb
|
253
256
|
- spec/extensions/composition_spec.rb
|
254
257
|
- spec/extensions/rcte_tree_spec.rb
|
255
258
|
- spec/extensions/instance_filters_spec.rb
|
256
259
|
- spec/extensions/sharding_spec.rb
|
257
260
|
- spec/extensions/skip_create_refresh_spec.rb
|
258
|
-
- spec/extensions/
|
261
|
+
- spec/extensions/date_arithmetic_spec.rb
|
259
262
|
- spec/extensions/update_primary_key_spec.rb
|
260
263
|
- spec/extensions/association_pks_spec.rb
|
261
264
|
- spec/extensions/json_serializer_spec.rb
|
@@ -304,6 +307,8 @@ files:
|
|
304
307
|
- spec/extensions/constraint_validations_spec.rb
|
305
308
|
- spec/extensions/connection_validator_spec.rb
|
306
309
|
- spec/extensions/validation_class_methods_spec.rb
|
310
|
+
- spec/extensions/meta_def_spec.rb
|
311
|
+
- spec/extensions/core_refinements_spec.rb
|
307
312
|
- spec/integration/associations_test.rb
|
308
313
|
- spec/integration/database_test.rb
|
309
314
|
- spec/integration/dataset_test.rb
|
@@ -505,7 +510,10 @@ files:
|
|
505
510
|
- lib/sequel/extensions/pg_row_ops.rb
|
506
511
|
- lib/sequel/extensions/constraint_validations.rb
|
507
512
|
- lib/sequel/extensions/connection_validator.rb
|
508
|
-
- lib/sequel/
|
513
|
+
- lib/sequel/extensions/date_arithmetic.rb
|
514
|
+
- lib/sequel/extensions/core_refinements.rb
|
515
|
+
- lib/sequel/extensions/meta_def.rb
|
516
|
+
- lib/sequel/version.rb
|
509
517
|
- lib/sequel/model.rb
|
510
518
|
- lib/sequel/model/associations.rb
|
511
519
|
- lib/sequel/model/base.rb
|
@@ -567,7 +575,6 @@ files:
|
|
567
575
|
- lib/sequel/plugins/pg_typecast_on_load.rb
|
568
576
|
- lib/sequel/plugins/constraint_validations.rb
|
569
577
|
- lib/sequel/timezones.rb
|
570
|
-
- lib/sequel/version.rb
|
571
578
|
- lib/sequel/ast_transformer.rb
|
572
579
|
- lib/sequel/no_core_ext.rb
|
573
580
|
- lib/sequel_core.rb
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Sequel
|
2
|
-
# Contains meta_def method for adding methods to objects via blocks, used by some of Sequel's classes and objects.
|
3
|
-
module Metaprogramming
|
4
|
-
# Define a method with the given name and block body on the receiver.
|
5
|
-
#
|
6
|
-
# ds = DB[:items]
|
7
|
-
# ds.meta_def(:x){42}
|
8
|
-
# ds.x # => 42
|
9
|
-
def meta_def(name, &block)
|
10
|
-
(class << self; self end).send(:define_method, name, &block)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|