sequel 2.5.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +48 -0
- data/Rakefile +16 -6
- data/bin/sequel +0 -0
- data/doc/cheat_sheet.rdoc +4 -4
- data/doc/schema.rdoc +9 -0
- data/lib/sequel_core/adapters/jdbc.rb +7 -7
- data/lib/sequel_core/adapters/mysql.rb +6 -11
- data/lib/sequel_core/adapters/shared/mssql.rb +21 -1
- data/lib/sequel_core/adapters/shared/mysql.rb +19 -27
- data/lib/sequel_core/adapters/shared/postgres.rb +67 -11
- data/lib/sequel_core/adapters/shared/sqlite.rb +11 -22
- data/lib/sequel_core/adapters/sqlite.rb +8 -4
- data/lib/sequel_core/core_sql.rb +4 -4
- data/lib/sequel_core/database.rb +56 -31
- data/lib/sequel_core/database/schema.rb +13 -5
- data/lib/sequel_core/dataset/convenience.rb +1 -1
- data/lib/sequel_core/dataset/sql.rb +30 -15
- data/lib/sequel_core/migration.rb +7 -0
- data/lib/sequel_core/schema/generator.rb +13 -2
- data/lib/sequel_core/schema/sql.rb +27 -81
- data/lib/sequel_core/sql.rb +5 -2
- data/lib/sequel_model.rb +8 -2
- data/lib/sequel_model/associations.rb +7 -4
- data/lib/sequel_model/base.rb +10 -1
- data/lib/sequel_model/eager_loading.rb +29 -10
- data/lib/sequel_model/record.rb +19 -5
- data/spec/adapters/mysql_spec.rb +2 -2
- data/spec/adapters/postgres_spec.rb +26 -5
- data/spec/adapters/sqlite_spec.rb +42 -8
- data/spec/integration/eager_loader_test.rb +51 -58
- data/spec/integration/schema_test.rb +28 -4
- data/spec/sequel_core/core_sql_spec.rb +3 -0
- data/spec/sequel_core/database_spec.rb +24 -0
- data/spec/sequel_core/dataset_spec.rb +25 -17
- data/spec/sequel_core/schema_spec.rb +58 -26
- data/spec/sequel_model/eager_loading_spec.rb +65 -0
- data/spec/sequel_model/hooks_spec.rb +1 -1
- data/spec/sequel_model/model_spec.rb +1 -0
- data/spec/sequel_model/record_spec.rb +74 -1
- data/spec/sequel_model/spec_helper.rb +8 -0
- metadata +5 -3
@@ -227,6 +227,7 @@ describe "Model#new?" do
|
|
227
227
|
|
228
228
|
@c = Class.new(Sequel::Model(:items)) do
|
229
229
|
unrestrict_primary_key
|
230
|
+
columns :x
|
230
231
|
end
|
231
232
|
end
|
232
233
|
|
@@ -441,6 +442,12 @@ describe Sequel::Model, "#set" do
|
|
441
442
|
returned_value.should == @o1
|
442
443
|
MODEL_DB.sqls.should == []
|
443
444
|
end
|
445
|
+
|
446
|
+
it "should assume it is a column if no column information is present and the key is a symbol" do
|
447
|
+
@c.instance_variable_set(:@columns, nil)
|
448
|
+
o = @c.new.set(:x123=>1)
|
449
|
+
o[:x123].should == 1
|
450
|
+
end
|
444
451
|
end
|
445
452
|
|
446
453
|
describe Sequel::Model, "#update" do
|
@@ -923,11 +930,30 @@ describe Sequel::Model, "typecasting" do
|
|
923
930
|
m.x.should == nil
|
924
931
|
end
|
925
932
|
|
933
|
+
specify "should not raise when typecasting nil to NOT NULL column but raise_on_typecast_failure is off" do
|
934
|
+
@c.raise_on_typecast_failure = false
|
935
|
+
@c.typecast_on_assignment = true
|
936
|
+
@c.instance_variable_set(:@db_schema, {:x=>{:type=>:integer,:allow_null=>false}})
|
937
|
+
m = @c.new
|
938
|
+
m.x = ''
|
939
|
+
m.x.should == nil
|
940
|
+
m.x = nil
|
941
|
+
m.x.should == nil
|
942
|
+
end
|
943
|
+
|
926
944
|
specify "should raise an error if invalid data is used in an integer field" do
|
927
945
|
@c.instance_variable_set(:@db_schema, {:x=>{:type=>:integer}})
|
928
946
|
proc{@c.new.x = 'a'}.should raise_error
|
929
947
|
end
|
930
948
|
|
949
|
+
specify "should assign value if raise_on_typecast_failure is off and assigning invalid integer" do
|
950
|
+
@c.raise_on_typecast_failure = false
|
951
|
+
@c.instance_variable_set(:@db_schema, {:x=>{:type=>:integer}})
|
952
|
+
model = @c.new
|
953
|
+
model.x = '1d'
|
954
|
+
model.x.should == '1d'
|
955
|
+
end
|
956
|
+
|
931
957
|
specify "should convert to float for a float field" do
|
932
958
|
@c.instance_variable_set(:@db_schema, {:x=>{:type=>:float}})
|
933
959
|
m = @c.new
|
@@ -944,6 +970,14 @@ describe Sequel::Model, "typecasting" do
|
|
944
970
|
proc{@c.new.x = 'a'}.should raise_error
|
945
971
|
end
|
946
972
|
|
973
|
+
specify "should assign value if raise_on_typecast_failure is off and assigning invalid float" do
|
974
|
+
@c.raise_on_typecast_failure = false
|
975
|
+
@c.instance_variable_set(:@db_schema, {:x=>{:type=>:float}})
|
976
|
+
model = @c.new
|
977
|
+
model.x = '1d'
|
978
|
+
model.x.should == '1d'
|
979
|
+
end
|
980
|
+
|
947
981
|
specify "should convert to BigDecimal for a decimal field" do
|
948
982
|
@c.instance_variable_set(:@db_schema, {:x=>{:type=>:decimal}})
|
949
983
|
m = @c.new
|
@@ -963,6 +997,15 @@ describe Sequel::Model, "typecasting" do
|
|
963
997
|
proc{@c.new.x = Date.today}.should raise_error
|
964
998
|
end
|
965
999
|
|
1000
|
+
specify "should assign value if raise_on_typecast_failure is off and assigning invalid decimal" do
|
1001
|
+
@c.raise_on_typecast_failure = false
|
1002
|
+
@c.instance_variable_set(:@db_schema, {:x=>{:type=>:decimal}})
|
1003
|
+
model = @c.new
|
1004
|
+
time = Time.now
|
1005
|
+
model.x = time
|
1006
|
+
model.x.should == time
|
1007
|
+
end
|
1008
|
+
|
966
1009
|
specify "should convert to string for a string field" do
|
967
1010
|
@c.instance_variable_set(:@db_schema, {:x=>{:type=>:string}})
|
968
1011
|
m = @c.new
|
@@ -1031,6 +1074,14 @@ describe Sequel::Model, "typecasting" do
|
|
1031
1074
|
proc{@c.new.x = 100}.should raise_error
|
1032
1075
|
end
|
1033
1076
|
|
1077
|
+
specify "should assign value if raise_on_typecast_failure is off and assigning invalid date" do
|
1078
|
+
@c.raise_on_typecast_failure = false
|
1079
|
+
@c.instance_variable_set(:@db_schema, {:x=>{:type=>:date}})
|
1080
|
+
model = @c.new
|
1081
|
+
model.x = 4
|
1082
|
+
model.x.should == 4
|
1083
|
+
end
|
1084
|
+
|
1034
1085
|
specify "should convert to time for a time field" do
|
1035
1086
|
@c.instance_variable_set(:@db_schema, {:x=>{:type=>:time}})
|
1036
1087
|
m = @c.new
|
@@ -1050,6 +1101,14 @@ describe Sequel::Model, "typecasting" do
|
|
1050
1101
|
proc{@c.new.x = '2008-10-21'.to_datetime}.should raise_error
|
1051
1102
|
end
|
1052
1103
|
|
1104
|
+
specify "should assign value if raise_on_typecast_failure is off and assigning invalid time" do
|
1105
|
+
@c.raise_on_typecast_failure = false
|
1106
|
+
@c.instance_variable_set(:@db_schema, {:x=>{:type=>:time}})
|
1107
|
+
model = @c.new
|
1108
|
+
model.x = '0000'
|
1109
|
+
model.x.should == '0000'
|
1110
|
+
end
|
1111
|
+
|
1053
1112
|
specify "should convert to the Sequel.datetime_class for a datetime field" do
|
1054
1113
|
@c.instance_variable_set(:@db_schema, {:x=>{:type=>:datetime}})
|
1055
1114
|
m = @c.new
|
@@ -1077,10 +1136,24 @@ describe Sequel::Model, "typecasting" do
|
|
1077
1136
|
|
1078
1137
|
specify "should raise an error if invalid data is used in a datetime field" do
|
1079
1138
|
@c.instance_variable_set(:@db_schema, {:x=>{:type=>:datetime}})
|
1080
|
-
proc{@c.new.x = '0000'}.should raise_error
|
1139
|
+
proc{@c.new.x = '0000'}.should raise_error(Sequel::Error::InvalidValue)
|
1081
1140
|
proc{@c.new.x = 'a'}.should_not raise_error # Valid Time
|
1082
1141
|
Sequel.datetime_class = DateTime
|
1083
1142
|
proc{@c.new.x = '0000'}.should raise_error
|
1084
1143
|
proc{@c.new.x = 'a'}.should raise_error
|
1085
1144
|
end
|
1145
|
+
|
1146
|
+
specify "should assign value if raise_on_typecast_failure is off and assigning invalid datetime" do
|
1147
|
+
@c.raise_on_typecast_failure = false
|
1148
|
+
@c.instance_variable_set(:@db_schema, {:x=>{:type=>:datetime}})
|
1149
|
+
model = @c.new
|
1150
|
+
model.x = '0000'
|
1151
|
+
model.x.should == '0000'
|
1152
|
+
Sequel.datetime_class = DateTime
|
1153
|
+
model = @c.new
|
1154
|
+
model.x = '0000'
|
1155
|
+
model.x.should == '0000'
|
1156
|
+
model.x = 'a'
|
1157
|
+
model.x.should == 'a'
|
1158
|
+
end
|
1086
1159
|
end
|
@@ -45,6 +45,14 @@ class MockDatabase < Sequel::Database
|
|
45
45
|
@sqls = []
|
46
46
|
end
|
47
47
|
|
48
|
+
def schema(table_name, opts)
|
49
|
+
if table_name
|
50
|
+
[[:id, {:primary_key=>true}]]
|
51
|
+
else
|
52
|
+
{table_name=>[[:id, {:primary_key=>true}]]}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
48
56
|
def transaction; yield; end
|
49
57
|
|
50
58
|
def dataset; MockDataset.new(self); 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: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-
|
12
|
+
date: 2008-10-11 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -28,6 +28,7 @@ extra_rdoc_files:
|
|
28
28
|
- doc/dataset_filtering.rdoc
|
29
29
|
- doc/prepared_statements.rdoc
|
30
30
|
- doc/sharding.rdoc
|
31
|
+
- doc/schema.rdoc
|
31
32
|
files:
|
32
33
|
- COPYING
|
33
34
|
- CHANGELOG
|
@@ -39,6 +40,7 @@ files:
|
|
39
40
|
- doc/dataset_filtering.rdoc
|
40
41
|
- doc/prepared_statements.rdoc
|
41
42
|
- doc/sharding.rdoc
|
43
|
+
- doc/schema.rdoc
|
42
44
|
- spec/adapters
|
43
45
|
- spec/adapters/informix_spec.rb
|
44
46
|
- spec/adapters/mysql_spec.rb
|
@@ -177,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
179
|
requirements: []
|
178
180
|
|
179
181
|
rubyforge_project: sequel
|
180
|
-
rubygems_version: 1.0
|
182
|
+
rubygems_version: 1.3.0
|
181
183
|
signing_key:
|
182
184
|
specification_version: 2
|
183
185
|
summary: The Database Toolkit for Ruby
|