sequel 3.26.0 → 3.27.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.
- data/CHANGELOG +26 -0
- data/Rakefile +2 -3
- data/doc/mass_assignment.rdoc +54 -0
- data/doc/migration.rdoc +9 -533
- data/doc/prepared_statements.rdoc +8 -7
- data/doc/release_notes/3.27.0.txt +82 -0
- data/doc/schema_modification.rdoc +547 -0
- data/doc/testing.rdoc +64 -0
- data/lib/sequel/adapters/amalgalite.rb +4 -0
- data/lib/sequel/adapters/jdbc.rb +3 -1
- data/lib/sequel/adapters/jdbc/h2.rb +11 -5
- data/lib/sequel/adapters/mysql.rb +4 -122
- data/lib/sequel/adapters/mysql2.rb +4 -13
- data/lib/sequel/adapters/odbc.rb +4 -1
- data/lib/sequel/adapters/odbc/db2.rb +21 -0
- data/lib/sequel/adapters/shared/mysql.rb +12 -0
- data/lib/sequel/adapters/shared/mysql_prepared_statements.rb +143 -0
- data/lib/sequel/adapters/tinytds.rb +122 -3
- data/lib/sequel/core.rb +4 -3
- data/lib/sequel/database/misc.rb +7 -10
- data/lib/sequel/dataset/misc.rb +1 -1
- data/lib/sequel/dataset/sql.rb +7 -0
- data/lib/sequel/model/associations.rb +2 -2
- data/lib/sequel/model/base.rb +60 -10
- data/lib/sequel/plugins/prepared_statements_safe.rb +17 -7
- data/lib/sequel/sql.rb +5 -0
- data/lib/sequel/timezones.rb +12 -3
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/mysql_spec.rb +25 -21
- data/spec/core/database_spec.rb +200 -0
- data/spec/core/dataset_spec.rb +6 -0
- data/spec/extensions/prepared_statements_safe_spec.rb +10 -0
- data/spec/extensions/schema_dumper_spec.rb +2 -2
- data/spec/integration/schema_test.rb +30 -1
- data/spec/integration/type_test.rb +10 -3
- data/spec/model/base_spec.rb +44 -0
- data/spec/model/model_spec.rb +14 -0
- data/spec/model/record_spec.rb +131 -12
- metadata +14 -4
data/spec/model/record_spec.rb
CHANGED
@@ -630,6 +630,40 @@ describe "Model#pk" do
|
|
630
630
|
end
|
631
631
|
end
|
632
632
|
|
633
|
+
describe "Model#pk_or_nil" do
|
634
|
+
before(:each) do
|
635
|
+
@m = Class.new(Sequel::Model)
|
636
|
+
@m.columns :id, :x, :y
|
637
|
+
end
|
638
|
+
|
639
|
+
it "should be default return the value of the :id column" do
|
640
|
+
m = @m.load(:id => 111, :x => 2, :y => 3)
|
641
|
+
m.pk_or_nil.should == 111
|
642
|
+
end
|
643
|
+
|
644
|
+
it "should be return the primary key value for custom primary key" do
|
645
|
+
@m.set_primary_key :x
|
646
|
+
m = @m.load(:id => 111, :x => 2, :y => 3)
|
647
|
+
m.pk_or_nil.should == 2
|
648
|
+
end
|
649
|
+
|
650
|
+
it "should be return the primary key value for composite primary key" do
|
651
|
+
@m.set_primary_key [:y, :x]
|
652
|
+
m = @m.load(:id => 111, :x => 2, :y => 3)
|
653
|
+
m.pk_or_nil.should == [3, 2]
|
654
|
+
end
|
655
|
+
|
656
|
+
it "should raise if no primary key" do
|
657
|
+
@m.set_primary_key nil
|
658
|
+
m = @m.new(:id => 111, :x => 2, :y => 3)
|
659
|
+
m.pk_or_nil.should be_nil
|
660
|
+
|
661
|
+
@m.no_primary_key
|
662
|
+
m = @m.new(:id => 111, :x => 2, :y => 3)
|
663
|
+
m.pk_or_nil.should be_nil
|
664
|
+
end
|
665
|
+
end
|
666
|
+
|
633
667
|
describe "Model#pk_hash" do
|
634
668
|
before(:each) do
|
635
669
|
@m = Class.new(Sequel::Model)
|
@@ -769,6 +803,32 @@ describe Sequel::Model, "#set" do
|
|
769
803
|
@o1.set(:x => 2, :z => 3)
|
770
804
|
@o1.values.should == {:x => 2, :z=>3}
|
771
805
|
end
|
806
|
+
|
807
|
+
it "#set should correctly handle cases where a module with a setter method is included in the class" do
|
808
|
+
@o1.set(:x => 1)
|
809
|
+
@o1.values.should == {:x => 1}
|
810
|
+
|
811
|
+
@c.send(:include, Module.new do
|
812
|
+
def z=(v)
|
813
|
+
self[:z] = v
|
814
|
+
end
|
815
|
+
end)
|
816
|
+
@o1.set(:x => 2, :z => 3)
|
817
|
+
@o1.values.should == {:x => 2, :z=>3}
|
818
|
+
end
|
819
|
+
|
820
|
+
it "#set should correctly handle cases where the object extends a module with a setter method " do
|
821
|
+
@o1.set(:x => 1)
|
822
|
+
@o1.values.should == {:x => 1}
|
823
|
+
|
824
|
+
@o1.extend(Module.new do
|
825
|
+
def z=(v)
|
826
|
+
self[:z] = v
|
827
|
+
end
|
828
|
+
end)
|
829
|
+
@o1.set(:x => 2, :z => 3)
|
830
|
+
@o1.values.should == {:x => 2, :z=>3}
|
831
|
+
end
|
772
832
|
end
|
773
833
|
|
774
834
|
describe Sequel::Model, "#update" do
|
@@ -1027,6 +1087,11 @@ describe Sequel::Model, "#exists?" do
|
|
1027
1087
|
@model.load(:id=>2).exists?.should be_false
|
1028
1088
|
MODEL_DB.sqls.should == ['SELECT 1 FROM items WHERE (id = 2) LIMIT 1']
|
1029
1089
|
end
|
1090
|
+
|
1091
|
+
it "should return false without issuing a query if the model object is new" do
|
1092
|
+
@model.new.exists?.should be_false
|
1093
|
+
MODEL_DB.sqls.should == []
|
1094
|
+
end
|
1030
1095
|
end
|
1031
1096
|
|
1032
1097
|
describe Sequel::Model, "#each" do
|
@@ -1124,13 +1189,10 @@ describe Sequel::Model, "#hash" do
|
|
1124
1189
|
y = Class.new(Sequel::Model)
|
1125
1190
|
y.columns :id, :x
|
1126
1191
|
a = z.load(:id => 1, :x => 3)
|
1127
|
-
b = z.load(:id => 1, :x => 4)
|
1128
|
-
c = z.load(:id => 2, :x => 3)
|
1129
|
-
d = y.load(:id => 1, :x => 3)
|
1130
1192
|
|
1131
|
-
a.hash.should ==
|
1132
|
-
a.hash.should_not ==
|
1133
|
-
a.hash.should_not ==
|
1193
|
+
a.hash.should == z.load(:id => 1, :x => 4).hash
|
1194
|
+
a.hash.should_not == z.load(:id => 2, :x => 3).hash
|
1195
|
+
a.hash.should_not == y.load(:id => 1, :x => 3).hash
|
1134
1196
|
end
|
1135
1197
|
|
1136
1198
|
specify "should be the same only for objects with the same class and values if the pk is nil" do
|
@@ -1139,14 +1201,71 @@ describe Sequel::Model, "#hash" do
|
|
1139
1201
|
y = Class.new(Sequel::Model)
|
1140
1202
|
y.columns :id, :x
|
1141
1203
|
a = z.new(:x => 3)
|
1142
|
-
b = z.new(:x => 4)
|
1143
|
-
c = z.new(:x => 3)
|
1144
|
-
d = y.new(:x => 3)
|
1145
1204
|
|
1146
|
-
a.hash.should_not ==
|
1147
|
-
a.hash.should ==
|
1148
|
-
a.hash.should_not ==
|
1205
|
+
a.hash.should_not == z.new(:x => 4).hash
|
1206
|
+
a.hash.should == z.new(:x => 3).hash
|
1207
|
+
a.hash.should_not == y.new(:x => 3).hash
|
1208
|
+
end
|
1209
|
+
|
1210
|
+
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
|
1211
|
+
z = Class.new(Sequel::Model)
|
1212
|
+
z.columns :id, :id2, :x
|
1213
|
+
z.set_primary_key(:id, :id2)
|
1214
|
+
y = Class.new(Sequel::Model)
|
1215
|
+
y.columns :id, :id2, :x
|
1216
|
+
y.set_primary_key(:id, :id2)
|
1217
|
+
a = z.load(:id => 1, :id2=>2, :x => 3)
|
1218
|
+
|
1219
|
+
a.hash.should == z.load(:id => 1, :id2=>2, :x => 4).hash
|
1220
|
+
a.hash.should_not == z.load(:id => 2, :id2=>1, :x => 3).hash
|
1221
|
+
a.hash.should_not == y.load(:id => 1, :id2=>1, :x => 3).hash
|
1222
|
+
end
|
1223
|
+
|
1224
|
+
specify "should be the same only for objects with the same class and value if pk is composite and one values is NULL" do
|
1225
|
+
z = Class.new(Sequel::Model)
|
1226
|
+
z.columns :id, :id2, :x
|
1227
|
+
z.set_primary_key(:id, :id2)
|
1228
|
+
y = Class.new(Sequel::Model)
|
1229
|
+
y.columns :id, :id2, :x
|
1230
|
+
y.set_primary_key(:id, :id2)
|
1231
|
+
|
1232
|
+
a = z.load(:id => 1, :id2 => nil, :x => 3)
|
1233
|
+
a.hash.should == z.load(:id => 1, :id2=>nil, :x => 3).hash
|
1234
|
+
a.hash.should_not == z.load(:id => 1, :id2=>nil, :x => 4).hash
|
1235
|
+
a.hash.should_not == y.load(:id => 1, :id2=>nil, :x => 3).hash
|
1236
|
+
|
1237
|
+
a = z.load(:id =>nil, :id2 => nil, :x => 3)
|
1238
|
+
a.hash.should == z.load(:id => nil, :id2=>nil, :x => 3).hash
|
1239
|
+
a.hash.should_not == z.load(:id => nil, :id2=>nil, :x => 4).hash
|
1240
|
+
a.hash.should_not == y.load(:id => nil, :id2=>nil, :x => 3).hash
|
1241
|
+
|
1242
|
+
a = z.load(:id => 1, :x => 3)
|
1243
|
+
a.hash.should == z.load(:id => 1, :x => 3).hash
|
1244
|
+
a.hash.should_not == z.load(:id => 1, :id2=>nil, :x => 3).hash
|
1245
|
+
a.hash.should_not == z.load(:id => 1, :x => 4).hash
|
1246
|
+
a.hash.should_not == y.load(:id => 1, :x => 3).hash
|
1247
|
+
|
1248
|
+
a = z.load(:x => 3)
|
1249
|
+
a.hash.should == z.load(:x => 3).hash
|
1250
|
+
a.hash.should_not == z.load(:id => nil, :id2=>nil, :x => 3).hash
|
1251
|
+
a.hash.should_not == z.load(:x => 4).hash
|
1252
|
+
a.hash.should_not == y.load(:x => 3).hash
|
1253
|
+
end
|
1254
|
+
|
1255
|
+
specify "should be the same only for objects with the same class and values if the no primary key" do
|
1256
|
+
z = Class.new(Sequel::Model)
|
1257
|
+
z.columns :id, :x
|
1258
|
+
z.no_primary_key
|
1259
|
+
y = Class.new(Sequel::Model)
|
1260
|
+
y.columns :id, :x
|
1261
|
+
y.no_primary_key
|
1262
|
+
a = z.new(:x => 3)
|
1263
|
+
|
1264
|
+
a.hash.should_not == z.new(:x => 4).hash
|
1265
|
+
a.hash.should == z.new(:x => 3).hash
|
1266
|
+
a.hash.should_not == y.new(:x => 3).hash
|
1149
1267
|
end
|
1268
|
+
|
1150
1269
|
end
|
1151
1270
|
|
1152
1271
|
describe Sequel::Model, "#initialize" do
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 107
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 3
|
8
|
-
-
|
8
|
+
- 27
|
9
9
|
- 0
|
10
|
-
version: 3.
|
10
|
+
version: 3.27.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jeremy Evans
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-09-01 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -45,6 +45,9 @@ extra_rdoc_files:
|
|
45
45
|
- doc/sql.rdoc
|
46
46
|
- doc/validations.rdoc
|
47
47
|
- doc/virtual_rows.rdoc
|
48
|
+
- doc/mass_assignment.rdoc
|
49
|
+
- doc/testing.rdoc
|
50
|
+
- doc/schema_modification.rdoc
|
48
51
|
- doc/release_notes/1.0.txt
|
49
52
|
- doc/release_notes/1.1.txt
|
50
53
|
- doc/release_notes/1.3.txt
|
@@ -90,6 +93,7 @@ extra_rdoc_files:
|
|
90
93
|
- doc/release_notes/3.8.0.txt
|
91
94
|
- doc/release_notes/3.9.0.txt
|
92
95
|
- doc/release_notes/3.26.0.txt
|
96
|
+
- doc/release_notes/3.27.0.txt
|
93
97
|
files:
|
94
98
|
- MIT-LICENSE
|
95
99
|
- CHANGELOG
|
@@ -153,10 +157,14 @@ files:
|
|
153
157
|
- doc/release_notes/3.8.0.txt
|
154
158
|
- doc/release_notes/3.9.0.txt
|
155
159
|
- doc/release_notes/3.26.0.txt
|
160
|
+
- doc/release_notes/3.27.0.txt
|
156
161
|
- doc/sharding.rdoc
|
157
162
|
- doc/sql.rdoc
|
158
163
|
- doc/validations.rdoc
|
159
164
|
- doc/virtual_rows.rdoc
|
165
|
+
- doc/mass_assignment.rdoc
|
166
|
+
- doc/testing.rdoc
|
167
|
+
- doc/schema_modification.rdoc
|
160
168
|
- spec/adapters/firebird_spec.rb
|
161
169
|
- spec/adapters/informix_spec.rb
|
162
170
|
- spec/adapters/mssql_spec.rb
|
@@ -327,6 +335,7 @@ files:
|
|
327
335
|
- lib/sequel/adapters/mysql.rb
|
328
336
|
- lib/sequel/adapters/odbc.rb
|
329
337
|
- lib/sequel/adapters/odbc/mssql.rb
|
338
|
+
- lib/sequel/adapters/odbc/db2.rb
|
330
339
|
- lib/sequel/adapters/openbase.rb
|
331
340
|
- lib/sequel/adapters/oracle.rb
|
332
341
|
- lib/sequel/adapters/postgres.rb
|
@@ -338,6 +347,7 @@ files:
|
|
338
347
|
- lib/sequel/adapters/shared/sqlite.rb
|
339
348
|
- lib/sequel/adapters/shared/access.rb
|
340
349
|
- lib/sequel/adapters/shared/informix.rb
|
350
|
+
- lib/sequel/adapters/shared/mysql_prepared_statements.rb
|
341
351
|
- lib/sequel/adapters/sqlite.rb
|
342
352
|
- lib/sequel/adapters/utils/stored_procedures.rb
|
343
353
|
- lib/sequel/adapters/mysql2.rb
|