sequel 3.45.0 → 3.46.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 +7 -0
- data/CHANGELOG +34 -0
- data/README.rdoc +6 -0
- data/Rakefile +46 -33
- data/doc/release_notes/3.46.0.txt +122 -0
- data/doc/schema_modification.rdoc +42 -6
- data/doc/security.rdoc +379 -0
- data/doc/transactions.rdoc +1 -1
- data/lib/sequel/adapters/jdbc/as400.rb +1 -0
- data/lib/sequel/adapters/jdbc/h2.rb +11 -0
- data/lib/sequel/adapters/mysql2.rb +3 -9
- data/lib/sequel/adapters/postgres.rb +34 -2
- data/lib/sequel/adapters/shared/cubrid.rb +5 -0
- data/lib/sequel/adapters/shared/mssql.rb +27 -3
- data/lib/sequel/adapters/shared/mysql.rb +25 -4
- data/lib/sequel/adapters/shared/sqlite.rb +12 -1
- data/lib/sequel/connection_pool.rb +3 -3
- data/lib/sequel/connection_pool/sharded_threaded.rb +7 -8
- data/lib/sequel/connection_pool/threaded.rb +7 -8
- data/lib/sequel/core.rb +5 -2
- data/lib/sequel/database.rb +1 -1
- data/lib/sequel/database/connecting.rb +7 -7
- data/lib/sequel/database/features.rb +88 -0
- data/lib/sequel/database/misc.rb +14 -64
- data/lib/sequel/database/query.rb +0 -332
- data/lib/sequel/database/schema_generator.rb +36 -3
- data/lib/sequel/database/schema_methods.rb +48 -12
- data/lib/sequel/database/transactions.rb +344 -0
- data/lib/sequel/dataset/actions.rb +24 -9
- data/lib/sequel/dataset/mutation.rb +20 -0
- data/lib/sequel/dataset/query.rb +0 -17
- data/lib/sequel/dataset/sql.rb +7 -0
- data/lib/sequel/exceptions.rb +10 -6
- data/lib/sequel/extensions/_pretty_table.rb +2 -2
- data/lib/sequel/extensions/looser_typecasting.rb +10 -0
- data/lib/sequel/extensions/migration.rb +5 -2
- data/lib/sequel/model.rb +1 -1
- data/lib/sequel/model/associations.rb +16 -14
- data/lib/sequel/model/base.rb +14 -2
- data/lib/sequel/plugins/composition.rb +3 -3
- data/lib/sequel/plugins/dirty.rb +6 -6
- data/lib/sequel/plugins/hook_class_methods.rb +3 -0
- data/lib/sequel/plugins/serialization.rb +7 -17
- data/lib/sequel/plugins/string_stripper.rb +2 -1
- data/lib/sequel/plugins/validation_helpers.rb +1 -1
- data/lib/sequel/sql.rb +3 -0
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/mssql_spec.rb +21 -0
- data/spec/adapters/postgres_spec.rb +35 -8
- data/spec/core/database_spec.rb +4 -0
- data/spec/core/dataset_spec.rb +48 -2
- data/spec/core/schema_generator_spec.rb +10 -1
- data/spec/core/schema_spec.rb +69 -0
- data/spec/extensions/composition_spec.rb +21 -2
- data/spec/extensions/dirty_spec.rb +17 -10
- data/spec/extensions/eager_each_spec.rb +4 -1
- data/spec/extensions/looser_typecasting_spec.rb +16 -19
- data/spec/extensions/migration_spec.rb +7 -1
- data/spec/extensions/serialization_spec.rb +22 -0
- data/spec/extensions/single_table_inheritance_spec.rb +3 -2
- data/spec/extensions/validation_helpers_spec.rb +6 -0
- data/spec/integration/dataset_test.rb +5 -0
- data/spec/integration/schema_test.rb +16 -0
- data/spec/model/associations_spec.rb +40 -0
- data/spec/model/base_spec.rb +21 -1
- data/spec/model/record_spec.rb +3 -0
- metadata +14 -10
@@ -128,6 +128,8 @@ describe "Reversible Migrations with Sequel.migration{change{}}" do
|
|
128
128
|
add_column :d, String
|
129
129
|
add_constraint :blah, 'd IS NOT NULL'
|
130
130
|
add_foreign_key :e, :b
|
131
|
+
add_foreign_key [:e], :b, :name=>'e_fk'
|
132
|
+
add_foreign_key [:e, :a], :b
|
131
133
|
add_primary_key :f, :b
|
132
134
|
add_index :e, :name=>'e_n'
|
133
135
|
add_full_text_index :e, :name=>'e_ft'
|
@@ -151,6 +153,8 @@ describe "Reversible Migrations with Sequel.migration{change{}}" do
|
|
151
153
|
[:add_column, :d, String],
|
152
154
|
[:add_constraint, :blah, "d IS NOT NULL"],
|
153
155
|
[:add_foreign_key, :e, :b],
|
156
|
+
[:add_foreign_key, [:e], :b, {:name=>"e_fk"}],
|
157
|
+
[:add_foreign_key, [:e, :a], :b],
|
154
158
|
[:add_primary_key, :f, :b],
|
155
159
|
[:add_index, :e, {:name=>"e_n"}],
|
156
160
|
[:add_full_text_index, :e, {:name=>"e_ft"}],
|
@@ -173,7 +177,9 @@ describe "Reversible Migrations with Sequel.migration{change{}}" do
|
|
173
177
|
[:drop_index, :e, {:name=>"e_ft"}],
|
174
178
|
[:drop_index, :e, {:name=>"e_n"}],
|
175
179
|
[:drop_column, :f],
|
176
|
-
[:
|
180
|
+
[:drop_foreign_key, [:e, :a]],
|
181
|
+
[:drop_foreign_key, [:e], {:name=>"e_fk"}],
|
182
|
+
[:drop_foreign_key, :e],
|
177
183
|
[:drop_constraint, :blah],
|
178
184
|
[:drop_column, :d]]
|
179
185
|
],
|
@@ -218,6 +218,17 @@ describe "Serialization plugin" do
|
|
218
218
|
"SELECT * FROM items WHERE (id = 10) LIMIT 1"]
|
219
219
|
end
|
220
220
|
|
221
|
+
it "should clear the deserialized columns when using set_values" do
|
222
|
+
@c.set_primary_key :id
|
223
|
+
@c.plugin :serialization, :yaml, :abc, :def
|
224
|
+
o = @c.load(:id => 1, :abc => "--- 1\n", :def => "--- hello\n")
|
225
|
+
o.abc = 23
|
226
|
+
o.deserialized_values.length.should == 1
|
227
|
+
o.abc.should == 23
|
228
|
+
o.set_values(:id=>1)
|
229
|
+
o.deserialized_values.length.should == 0
|
230
|
+
end
|
231
|
+
|
221
232
|
it "should clear the deserialized columns when refreshing" do
|
222
233
|
@c.set_primary_key :id
|
223
234
|
@c.plugin :serialization, :yaml, :abc, :def
|
@@ -238,6 +249,17 @@ describe "Serialization plugin" do
|
|
238
249
|
o.deserialized_values.length.should == 0
|
239
250
|
end
|
240
251
|
|
252
|
+
it "should clear the deserialized columns when refreshing after saving a new object with insert_select" do
|
253
|
+
@c.set_primary_key :id
|
254
|
+
@c.plugin :serialization, :yaml, :abc, :def
|
255
|
+
def (@c.instance_dataset).supports_insert_select?() true end
|
256
|
+
def (@c.instance_dataset).insert_select(*) {:id=>1} end
|
257
|
+
o = @c.new(:abc => "--- 1\n", :def => "--- hello\n")
|
258
|
+
o.deserialized_values.length.should == 2
|
259
|
+
o.save
|
260
|
+
o.deserialized_values.length.should == 0
|
261
|
+
end
|
262
|
+
|
241
263
|
it "should raise an error if calling internal serialization methods with bad columns" do
|
242
264
|
@c.set_primary_key :id
|
243
265
|
@c.plugin :serialization
|
@@ -193,7 +193,7 @@ describe Sequel::Model, "#sti_key" do
|
|
193
193
|
StiTest2.dataset.row_proc.call(:kind=>1).should be_a_instance_of(StiTest3)
|
194
194
|
StiTest2.dataset.row_proc.call(:kind=>2).should be_a_instance_of(StiTest4)
|
195
195
|
|
196
|
-
StiTest3.create.kind
|
196
|
+
[0,1].should include(StiTest3.create.kind)
|
197
197
|
StiTest4.create.kind.should == 2
|
198
198
|
end
|
199
199
|
|
@@ -214,7 +214,8 @@ describe Sequel::Model, "#sti_key" do
|
|
214
214
|
class ::StiTest4 < ::StiTest2; end
|
215
215
|
|
216
216
|
StiTest2.dataset.sql.should == "SELECT * FROM sti_test2s"
|
217
|
-
|
217
|
+
["SELECT * FROM sti_test2s WHERE (sti_test2s.kind IN (0, 1))",
|
218
|
+
"SELECT * FROM sti_test2s WHERE (sti_test2s.kind IN (1, 0))"].should include(StiTest3.dataset.sql)
|
218
219
|
end
|
219
220
|
|
220
221
|
it "should honor a :key_chooser" do
|
@@ -294,6 +294,12 @@ describe "Sequel::Plugins::ValidationHelpers" do
|
|
294
294
|
@m.value = 123.05
|
295
295
|
@m.should_not be_valid
|
296
296
|
@m.errors.full_messages.should == ['value is not a Integer']
|
297
|
+
|
298
|
+
@c.set_validations{validates_type(Integer, :value)}
|
299
|
+
@m.value = nil
|
300
|
+
@m.should be_valid
|
301
|
+
@m.value = false
|
302
|
+
@m.should_not be_valid
|
297
303
|
end
|
298
304
|
|
299
305
|
specify "should support validates_presence" do
|
@@ -361,6 +361,11 @@ describe Sequel::Database do
|
|
361
361
|
INTEGRATION_DB.get(Sequel.cast(Sequel.blob("\1\2\3"), File).as(:a)).should == "\1\2\3"
|
362
362
|
end
|
363
363
|
|
364
|
+
cspecify "should properly escape identifiers", :db2, :oracle do
|
365
|
+
INTEGRATION_DB.create_table(:"\\'\"[]"){Integer :id}
|
366
|
+
INTEGRATION_DB.drop_table(:"\\'\"[]")
|
367
|
+
end
|
368
|
+
|
364
369
|
specify "should have a working table_exists?" do
|
365
370
|
t = :basdfdsafsaddsaf
|
366
371
|
INTEGRATION_DB.drop_table?(t)
|
@@ -237,6 +237,15 @@ describe "Database foreign key parsing" do
|
|
237
237
|
@db.alter_table(:a){add_index [:d, :c], :unique=>true}
|
238
238
|
@db.alter_table(:b){add_foreign_key [:f, :e], :a, :key=>[:d, :c]}
|
239
239
|
@pr[:b, [[:e], :a, [:pk, :c]], [[:f], :a, [:c]], [[:f], :a, [:d]], [[:f, :e], :a, [:d, :c]]]
|
240
|
+
|
241
|
+
@db.alter_table(:b){drop_foreign_key [:f, :e]}
|
242
|
+
@pr[:b, [[:e], :a, [:pk, :c]], [[:f], :a, [:c]], [[:f], :a, [:d]]]
|
243
|
+
|
244
|
+
@db.alter_table(:b){drop_foreign_key :e}
|
245
|
+
@pr[:b, [[:f], :a, [:c]], [[:f], :a, [:d]]]
|
246
|
+
|
247
|
+
proc{@db.alter_table(:b){drop_foreign_key :f}}.should raise_error(Sequel::Error)
|
248
|
+
@pr[:b, [[:f], :a, [:c]], [[:f], :a, [:d]]]
|
240
249
|
end
|
241
250
|
|
242
251
|
specify "should handle composite foreign and primary keys" do
|
@@ -367,6 +376,13 @@ describe "Database schema modifiers" do
|
|
367
376
|
@ds.insert([10])
|
368
377
|
end
|
369
378
|
|
379
|
+
specify "should be able to specify constraint names for column constraints" do
|
380
|
+
@db.create_table!(:items2){primary_key :id, :primary_key_constraint_name=>:foo_pk}
|
381
|
+
@db.create_table!(:items){foreign_key :id, :items2, :unique=>true, :foreign_key_constraint_name => :foo_fk, :unique_constraint_name => :foo_uk, :null=>false}
|
382
|
+
@db.alter_table(:items){drop_constraint :foo_fk, :type=>:foreign_key; drop_constraint :foo_uk, :type=>:unique}
|
383
|
+
@db.alter_table(:items2){drop_constraint :foo_pk, :type=>:primary_key}
|
384
|
+
end
|
385
|
+
|
370
386
|
specify "should handle foreign keys correctly when creating tables" do
|
371
387
|
@db.create_table!(:items) do
|
372
388
|
primary_key :id
|
@@ -137,6 +137,46 @@ describe Sequel::Model, "associate" do
|
|
137
137
|
proc{c.one_to_many :cs, :clone=>:c}.should_not raise_error(Sequel::Error)
|
138
138
|
proc{c.one_to_one :c2, :clone=>:cs}.should_not raise_error(Sequel::Error)
|
139
139
|
end
|
140
|
+
|
141
|
+
it "should clear associations cache when using set_values" do
|
142
|
+
c = Class.new(Sequel::Model(:c))
|
143
|
+
c.many_to_one :c
|
144
|
+
o = c.new
|
145
|
+
o.associations[:c] = 1
|
146
|
+
o.set_values(:id=>1)
|
147
|
+
o.associations.should == {}
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should clear associations cache when refreshing object manually" do
|
151
|
+
c = Class.new(Sequel::Model(:c))
|
152
|
+
c.many_to_one :c
|
153
|
+
o = c.new
|
154
|
+
o.associations[:c] = 1
|
155
|
+
o.refresh
|
156
|
+
o.associations.should == {}
|
157
|
+
end
|
158
|
+
|
159
|
+
it "should clear associations cache when refreshing object after save" do
|
160
|
+
c = Class.new(Sequel::Model(:c))
|
161
|
+
c.many_to_one :c
|
162
|
+
o = c.new
|
163
|
+
o.associations[:c] = 1
|
164
|
+
o.save
|
165
|
+
o.associations.should == {}
|
166
|
+
end
|
167
|
+
|
168
|
+
it "should clear associations cache when saving with insert_select" do
|
169
|
+
ds = Sequel::Model.db[:c]
|
170
|
+
def ds.supports_insert_select?() true end
|
171
|
+
def ds.insert_select(*) {:id=>1} end
|
172
|
+
c = Class.new(Sequel::Model(ds))
|
173
|
+
c.many_to_one :c
|
174
|
+
o = c.new
|
175
|
+
o.associations[:c] = 1
|
176
|
+
o.save
|
177
|
+
o.associations.should == {}
|
178
|
+
end
|
179
|
+
|
140
180
|
end
|
141
181
|
|
142
182
|
describe Sequel::Model, "many_to_one" do
|
data/spec/model/base_spec.rb
CHANGED
@@ -693,7 +693,7 @@ describe Sequel::Model, ".[] optimization" do
|
|
693
693
|
end
|
694
694
|
end
|
695
695
|
|
696
|
-
describe "Model datasets #with_pk" do
|
696
|
+
describe "Model datasets #with_pk with #with_pk!" do
|
697
697
|
before do
|
698
698
|
@c = Class.new(Sequel::Model(:a))
|
699
699
|
@ds = @c.dataset
|
@@ -704,16 +704,22 @@ describe "Model datasets #with_pk" do
|
|
704
704
|
it "should return the first record where the primary key matches" do
|
705
705
|
@ds.with_pk(1).should == @c.load(:id=>1)
|
706
706
|
MODEL_DB.sqls.should == ["SELECT * FROM a WHERE (a.id = 1) LIMIT 1"]
|
707
|
+
@ds.with_pk!(1).should == @c.load(:id=>1)
|
708
|
+
MODEL_DB.sqls.should == ["SELECT * FROM a WHERE (a.id = 1) LIMIT 1"]
|
707
709
|
end
|
708
710
|
|
709
711
|
it "should handle existing filters" do
|
710
712
|
@ds.filter(:a=>2).with_pk(1)
|
711
713
|
MODEL_DB.sqls.should == ["SELECT * FROM a WHERE ((a = 2) AND (a.id = 1)) LIMIT 1"]
|
714
|
+
@ds.filter(:a=>2).with_pk!(1)
|
715
|
+
MODEL_DB.sqls.should == ["SELECT * FROM a WHERE ((a = 2) AND (a.id = 1)) LIMIT 1"]
|
712
716
|
end
|
713
717
|
|
714
718
|
it "should work with string values" do
|
715
719
|
@ds.with_pk("foo")
|
716
720
|
MODEL_DB.sqls.should == ["SELECT * FROM a WHERE (a.id = 'foo') LIMIT 1"]
|
721
|
+
@ds.with_pk!("foo")
|
722
|
+
MODEL_DB.sqls.should == ["SELECT * FROM a WHERE (a.id = 'foo') LIMIT 1"]
|
717
723
|
end
|
718
724
|
|
719
725
|
it "should handle an array for composite primary keys" do
|
@@ -723,6 +729,20 @@ describe "Model datasets #with_pk" do
|
|
723
729
|
["SELECT * FROM a WHERE ((a.id1 = 1) AND (a.id2 = 2)) LIMIT 1",
|
724
730
|
"SELECT * FROM a WHERE ((a.id2 = 2) AND (a.id1 = 1)) LIMIT 1"].should include(sqls.pop)
|
725
731
|
sqls.should == []
|
732
|
+
|
733
|
+
@ds.with_pk!([1, 2])
|
734
|
+
sqls = MODEL_DB.sqls
|
735
|
+
["SELECT * FROM a WHERE ((a.id1 = 1) AND (a.id2 = 2)) LIMIT 1",
|
736
|
+
"SELECT * FROM a WHERE ((a.id2 = 2) AND (a.id1 = 1)) LIMIT 1"].should include(sqls.pop)
|
737
|
+
sqls.should == []
|
738
|
+
end
|
739
|
+
|
740
|
+
it "should have with_pk return nil and with_pk! raise if no rows match" do
|
741
|
+
@ds._fetch = []
|
742
|
+
@ds.with_pk(1).should == nil
|
743
|
+
MODEL_DB.sqls.should == ["SELECT * FROM a WHERE (a.id = 1) LIMIT 1"]
|
744
|
+
proc{@ds.with_pk!(1)}.should raise_error(Sequel::NoMatchingRow)
|
745
|
+
MODEL_DB.sqls.should == ["SELECT * FROM a WHERE (a.id = 1) LIMIT 1"]
|
726
746
|
end
|
727
747
|
|
728
748
|
it "should have #[] consider an integer as a primary key lookup" do
|
data/spec/model/record_spec.rb
CHANGED
@@ -1642,11 +1642,14 @@ describe Sequel::Model, "typecasting" do
|
|
1642
1642
|
m.x.should == bd
|
1643
1643
|
m.x = bd
|
1644
1644
|
m.x.should == bd
|
1645
|
+
m.x = '0'
|
1646
|
+
m.x.should == 0
|
1645
1647
|
end
|
1646
1648
|
|
1647
1649
|
specify "should raise an error if invalid data is used in an decimal field" do
|
1648
1650
|
@c.db_schema = {:x=>{:type=>:decimal}}
|
1649
1651
|
proc{@c.new.x = Date.today}.should raise_error(Sequel::InvalidValue)
|
1652
|
+
proc{@c.new.x = 'foo'}.should raise_error(Sequel::InvalidValue)
|
1650
1653
|
end
|
1651
1654
|
|
1652
1655
|
specify "should assign value if raise_on_typecast_failure is off and assigning invalid decimal" do
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
5
|
-
prerelease:
|
4
|
+
version: 3.46.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jeremy Evans
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-04-02 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: The Database Toolkit for Ruby
|
15
14
|
email: code@jeremyevans.net
|
@@ -44,6 +43,7 @@ extra_rdoc_files:
|
|
44
43
|
- doc/object_model.rdoc
|
45
44
|
- doc/core_extensions.rdoc
|
46
45
|
- doc/bin_sequel.rdoc
|
46
|
+
- doc/security.rdoc
|
47
47
|
- doc/release_notes/1.0.txt
|
48
48
|
- doc/release_notes/1.1.txt
|
49
49
|
- doc/release_notes/1.3.txt
|
@@ -108,6 +108,7 @@ extra_rdoc_files:
|
|
108
108
|
- doc/release_notes/3.43.0.txt
|
109
109
|
- doc/release_notes/3.44.0.txt
|
110
110
|
- doc/release_notes/3.45.0.txt
|
111
|
+
- doc/release_notes/3.46.0.txt
|
111
112
|
files:
|
112
113
|
- MIT-LICENSE
|
113
114
|
- CHANGELOG
|
@@ -190,6 +191,7 @@ files:
|
|
190
191
|
- doc/release_notes/3.43.0.txt
|
191
192
|
- doc/release_notes/3.44.0.txt
|
192
193
|
- doc/release_notes/3.45.0.txt
|
194
|
+
- doc/release_notes/3.46.0.txt
|
193
195
|
- doc/sharding.rdoc
|
194
196
|
- doc/sql.rdoc
|
195
197
|
- doc/validations.rdoc
|
@@ -202,6 +204,7 @@ files:
|
|
202
204
|
- doc/object_model.rdoc
|
203
205
|
- doc/core_extensions.rdoc
|
204
206
|
- doc/bin_sequel.rdoc
|
207
|
+
- doc/security.rdoc
|
205
208
|
- spec/adapters/firebird_spec.rb
|
206
209
|
- spec/adapters/informix_spec.rb
|
207
210
|
- spec/adapters/mssql_spec.rb
|
@@ -467,6 +470,8 @@ files:
|
|
467
470
|
- lib/sequel/database/logging.rb
|
468
471
|
- lib/sequel/database/misc.rb
|
469
472
|
- lib/sequel/database/query.rb
|
473
|
+
- lib/sequel/database/features.rb
|
474
|
+
- lib/sequel/database/transactions.rb
|
470
475
|
- lib/sequel/dataset.rb
|
471
476
|
- lib/sequel/dataset/actions.rb
|
472
477
|
- lib/sequel/dataset/features.rb
|
@@ -588,33 +593,32 @@ files:
|
|
588
593
|
- lib/sequel_model.rb
|
589
594
|
homepage: http://sequel.rubyforge.org
|
590
595
|
licenses: []
|
596
|
+
metadata: {}
|
591
597
|
post_install_message:
|
592
598
|
rdoc_options:
|
593
599
|
- --quiet
|
594
600
|
- --line-numbers
|
595
601
|
- --inline-source
|
596
602
|
- --title
|
597
|
-
-
|
603
|
+
- 'Sequel: The Database Toolkit for Ruby'
|
598
604
|
- --main
|
599
605
|
- README.rdoc
|
600
606
|
require_paths:
|
601
607
|
- lib
|
602
608
|
required_ruby_version: !ruby/object:Gem::Requirement
|
603
|
-
none: false
|
604
609
|
requirements:
|
605
|
-
- -
|
610
|
+
- - '>='
|
606
611
|
- !ruby/object:Gem::Version
|
607
612
|
version: 1.8.7
|
608
613
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
609
|
-
none: false
|
610
614
|
requirements:
|
611
|
-
- -
|
615
|
+
- - '>='
|
612
616
|
- !ruby/object:Gem::Version
|
613
617
|
version: '0'
|
614
618
|
requirements: []
|
615
619
|
rubyforge_project: sequel
|
616
|
-
rubygems_version:
|
620
|
+
rubygems_version: 2.0.0
|
617
621
|
signing_key:
|
618
|
-
specification_version:
|
622
|
+
specification_version: 4
|
619
623
|
summary: The Database Toolkit for Ruby
|
620
624
|
test_files: []
|