sequel 3.3.0 → 3.4.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 +62 -0
- data/README.rdoc +4 -4
- data/doc/release_notes/3.3.0.txt +1 -1
- data/doc/release_notes/3.4.0.txt +325 -0
- data/doc/sharding.rdoc +3 -3
- data/lib/sequel/adapters/amalgalite.rb +1 -1
- data/lib/sequel/adapters/firebird.rb +4 -9
- data/lib/sequel/adapters/jdbc.rb +21 -7
- data/lib/sequel/adapters/mysql.rb +2 -1
- data/lib/sequel/adapters/odbc.rb +7 -21
- data/lib/sequel/adapters/oracle.rb +1 -1
- data/lib/sequel/adapters/postgres.rb +6 -1
- data/lib/sequel/adapters/shared/mssql.rb +11 -0
- data/lib/sequel/adapters/shared/mysql.rb +8 -12
- data/lib/sequel/adapters/shared/oracle.rb +13 -0
- data/lib/sequel/adapters/shared/postgres.rb +5 -10
- data/lib/sequel/adapters/shared/sqlite.rb +21 -1
- data/lib/sequel/adapters/sqlite.rb +2 -2
- data/lib/sequel/core.rb +147 -11
- data/lib/sequel/database.rb +21 -9
- data/lib/sequel/dataset.rb +31 -6
- data/lib/sequel/dataset/convenience.rb +1 -1
- data/lib/sequel/dataset/sql.rb +76 -18
- data/lib/sequel/extensions/inflector.rb +2 -51
- data/lib/sequel/model.rb +16 -10
- data/lib/sequel/model/associations.rb +4 -1
- data/lib/sequel/model/base.rb +13 -6
- data/lib/sequel/model/default_inflections.rb +46 -0
- data/lib/sequel/model/inflections.rb +1 -51
- data/lib/sequel/plugins/boolean_readers.rb +52 -0
- data/lib/sequel/plugins/instance_hooks.rb +57 -0
- data/lib/sequel/plugins/lazy_attributes.rb +13 -1
- data/lib/sequel/plugins/nested_attributes.rb +171 -0
- data/lib/sequel/plugins/serialization.rb +35 -16
- data/lib/sequel/plugins/timestamps.rb +87 -0
- data/lib/sequel/plugins/validation_helpers.rb +8 -1
- data/lib/sequel/sql.rb +33 -0
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/sqlite_spec.rb +11 -6
- data/spec/core/core_sql_spec.rb +29 -0
- data/spec/core/database_spec.rb +16 -7
- data/spec/core/dataset_spec.rb +264 -20
- data/spec/extensions/boolean_readers_spec.rb +86 -0
- data/spec/extensions/inflector_spec.rb +67 -4
- data/spec/extensions/instance_hooks_spec.rb +133 -0
- data/spec/extensions/lazy_attributes_spec.rb +45 -5
- data/spec/extensions/nested_attributes_spec.rb +272 -0
- data/spec/extensions/serialization_spec.rb +64 -1
- data/spec/extensions/timestamps_spec.rb +150 -0
- data/spec/extensions/validation_helpers_spec.rb +18 -0
- data/spec/integration/dataset_test.rb +79 -2
- data/spec/integration/schema_test.rb +17 -0
- data/spec/integration/timezone_test.rb +55 -0
- data/spec/model/associations_spec.rb +19 -7
- data/spec/model/model_spec.rb +29 -0
- data/spec/model/record_spec.rb +36 -0
- data/spec/spec_config.rb +1 -1
- metadata +14 -2
@@ -1207,7 +1207,7 @@ end
|
|
1207
1207
|
|
1208
1208
|
describe Sequel::Model, "many_to_many" do
|
1209
1209
|
|
1210
|
-
before
|
1210
|
+
before do
|
1211
1211
|
MODEL_DB.reset
|
1212
1212
|
|
1213
1213
|
@c1 = Class.new(Sequel::Model(:attributes)) do
|
@@ -1216,6 +1216,10 @@ describe Sequel::Model, "many_to_many" do
|
|
1216
1216
|
def self.name; 'Attribute'; end
|
1217
1217
|
def self.to_s; 'Attribute'; end
|
1218
1218
|
columns :id
|
1219
|
+
def _refresh(ds)
|
1220
|
+
self.id = 1
|
1221
|
+
self
|
1222
|
+
end
|
1219
1223
|
end
|
1220
1224
|
|
1221
1225
|
@c2 = Class.new(Sequel::Model(:nodes)) do
|
@@ -1403,8 +1407,8 @@ describe Sequel::Model, "many_to_many" do
|
|
1403
1407
|
it "should define an add_ method" do
|
1404
1408
|
@c2.many_to_many :attributes, :class => @c1
|
1405
1409
|
|
1406
|
-
n = @c2.
|
1407
|
-
a = @c1.
|
1410
|
+
n = @c2.load(:id => 1234)
|
1411
|
+
a = @c1.load(:id => 2345)
|
1408
1412
|
a.should == n.add_attribute(a)
|
1409
1413
|
['INSERT INTO attributes_nodes (node_id, attribute_id) VALUES (1234, 2345)',
|
1410
1414
|
'INSERT INTO attributes_nodes (attribute_id, node_id) VALUES (2345, 1234)'
|
@@ -1423,8 +1427,8 @@ describe Sequel::Model, "many_to_many" do
|
|
1423
1427
|
it "should have the add_ method respect the :left_primary_key and :right_primary_key options" do
|
1424
1428
|
@c2.many_to_many :attributes, :class => @c1, :left_primary_key=>:xxx, :right_primary_key=>:yyy
|
1425
1429
|
|
1426
|
-
n = @c2.
|
1427
|
-
a = @c1.
|
1430
|
+
n = @c2.load(:id => 1234).set(:xxx=>5)
|
1431
|
+
a = @c1.load(:id => 2345).set(:yyy=>8)
|
1428
1432
|
a.should == n.add_attribute(a)
|
1429
1433
|
['INSERT INTO attributes_nodes (node_id, attribute_id) VALUES (5, 8)',
|
1430
1434
|
'INSERT INTO attributes_nodes (attribute_id, node_id) VALUES (8, 5)'
|
@@ -1450,12 +1454,20 @@ describe Sequel::Model, "many_to_many" do
|
|
1450
1454
|
proc{a.remove_attribute(n)}.should raise_error(Sequel::Error)
|
1451
1455
|
proc{a.remove_all_attributes}.should raise_error(Sequel::Error)
|
1452
1456
|
end
|
1457
|
+
|
1458
|
+
it "should save the associated object first if passed a new model object" do
|
1459
|
+
@c2.many_to_many :attributes, :class => @c1
|
1460
|
+
n = @c1.new
|
1461
|
+
a = @c2.load(:id=>123)
|
1462
|
+
n.new?.should == true
|
1463
|
+
a.add_attribute(n)
|
1464
|
+
n.new?.should == false
|
1465
|
+
end
|
1453
1466
|
|
1454
|
-
it "should raise an error if trying to
|
1467
|
+
it "should raise an error if trying to remove a model object that doesn't have a valid primary key" do
|
1455
1468
|
@c2.many_to_many :attributes, :class => @c1
|
1456
1469
|
n = @c1.new
|
1457
1470
|
a = @c2.load(:id=>123)
|
1458
|
-
proc{a.add_attribute(n)}.should raise_error(Sequel::Error)
|
1459
1471
|
proc{a.remove_attribute(n)}.should raise_error(Sequel::Error)
|
1460
1472
|
end
|
1461
1473
|
|
data/spec/model/model_spec.rb
CHANGED
@@ -1,5 +1,34 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), "spec_helper")
|
2
2
|
|
3
|
+
describe "Sequel::Model()" do
|
4
|
+
before do
|
5
|
+
@db = Sequel::Model.db
|
6
|
+
end
|
7
|
+
it "should return a model subclass with the given dataset if given a dataset" do
|
8
|
+
ds = @db[:blah]
|
9
|
+
c = Sequel::Model(ds)
|
10
|
+
c.superclass.should == Sequel::Model
|
11
|
+
c.dataset.should == ds
|
12
|
+
end
|
13
|
+
it "should return a model subclass with a dataset with the default database and given table name if given a symbol" do
|
14
|
+
c = Sequel::Model(:blah)
|
15
|
+
c.superclass.should == Sequel::Model
|
16
|
+
c.db.should == @db
|
17
|
+
c.table_name.should == :blah
|
18
|
+
end
|
19
|
+
it "should return a model subclass associated to the given database if given a database" do
|
20
|
+
db = Sequel::Database.new
|
21
|
+
c = Sequel::Model(db)
|
22
|
+
c.superclass.should == Sequel::Model
|
23
|
+
c.db.should == db
|
24
|
+
proc{c.dataset}.should raise_error(Sequel::Error)
|
25
|
+
class SmBlahTest < c
|
26
|
+
end
|
27
|
+
SmBlahTest.db.should == db
|
28
|
+
SmBlahTest.table_name.should == :sm_blah_tests
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
3
32
|
describe Sequel::Model do
|
4
33
|
it "should have class method aliased as model" do
|
5
34
|
Sequel::Model.instance_methods.collect{|x| x.to_s}.should include("model")
|
data/spec/model/record_spec.rb
CHANGED
@@ -1120,6 +1120,16 @@ describe Sequel::Model, "typecasting" do
|
|
1120
1120
|
m.x.should == y
|
1121
1121
|
end
|
1122
1122
|
|
1123
|
+
specify "should accept a hash with symbol or string keys for a date field" do
|
1124
|
+
@c.instance_variable_set(:@db_schema, {:x=>{:type=>:date}})
|
1125
|
+
m = @c.new
|
1126
|
+
y = Date.new(2007,10,21)
|
1127
|
+
m.x = {:year=>2007, :month=>10, :day=>21}
|
1128
|
+
m.x.should == y
|
1129
|
+
m.x = {'year'=>'2007', 'month'=>'10', 'day'=>'21'}
|
1130
|
+
m.x.should == y
|
1131
|
+
end
|
1132
|
+
|
1123
1133
|
specify "should raise an error if invalid data is used in a date field" do
|
1124
1134
|
@c.instance_variable_set(:@db_schema, {:x=>{:type=>:date}})
|
1125
1135
|
proc{@c.new.x = 'a'}.should raise_error(Sequel::InvalidValue)
|
@@ -1145,6 +1155,16 @@ describe Sequel::Model, "typecasting" do
|
|
1145
1155
|
m.x.should == y
|
1146
1156
|
end
|
1147
1157
|
|
1158
|
+
specify "should accept a hash with symbol or string keys for a time field" do
|
1159
|
+
@c.instance_variable_set(:@db_schema, {:x=>{:type=>:time}})
|
1160
|
+
m = @c.new
|
1161
|
+
y = Time.parse('10:20:30')
|
1162
|
+
m.x = {:hour=>10, :minute=>20, :second=>30}
|
1163
|
+
m.x.should == y
|
1164
|
+
m.x = {'hour'=>'10', 'minute'=>'20', 'second'=>'30'}
|
1165
|
+
m.x.should == y
|
1166
|
+
end
|
1167
|
+
|
1148
1168
|
specify "should raise an error if invalid data is used in a time field" do
|
1149
1169
|
@c.instance_variable_set(:@db_schema, {:x=>{:type=>:time}})
|
1150
1170
|
proc{@c.new.x = '0000'}.should raise_error
|
@@ -1186,6 +1206,22 @@ describe Sequel::Model, "typecasting" do
|
|
1186
1206
|
m.x.should == DateTime.parse('2007-10-21')
|
1187
1207
|
end
|
1188
1208
|
|
1209
|
+
specify "should accept a hash with symbol or string keys for a datetime field" do
|
1210
|
+
@c.instance_variable_set(:@db_schema, {:x=>{:type=>:datetime}})
|
1211
|
+
m = @c.new
|
1212
|
+
y = Time.parse('2007-10-21 10:20:30')
|
1213
|
+
m.x = {:year=>2007, :month=>10, :day=>21, :hour=>10, :minute=>20, :second=>30}
|
1214
|
+
m.x.should == y
|
1215
|
+
m.x = {'year'=>'2007', 'month'=>'10', 'day'=>'21', 'hour'=>'10', 'minute'=>'20', 'second'=>'30'}
|
1216
|
+
m.x.should == y
|
1217
|
+
Sequel.datetime_class = DateTime
|
1218
|
+
y = DateTime.parse('2007-10-21 10:20:30')
|
1219
|
+
m.x = {:year=>2007, :month=>10, :day=>21, :hour=>10, :minute=>20, :second=>30}
|
1220
|
+
m.x.should == y
|
1221
|
+
m.x = {'year'=>'2007', 'month'=>'10', 'day'=>'21', 'hour'=>'10', 'minute'=>'20', 'second'=>'30'}
|
1222
|
+
m.x.should == y
|
1223
|
+
end
|
1224
|
+
|
1189
1225
|
specify "should raise an error if invalid data is used in a datetime field" do
|
1190
1226
|
@c.instance_variable_set(:@db_schema, {:x=>{:type=>:datetime}})
|
1191
1227
|
proc{@c.new.x = '0000'}.should raise_error(Sequel::InvalidValue)
|
data/spec/spec_config.rb
CHANGED
@@ -6,5 +6,5 @@
|
|
6
6
|
# MYSQL_URL = "mysql://#{MYSQL_USER}@localhost/sandbox"
|
7
7
|
# MYSQL_SOCKET_FILE = '/tmp/mysql.sock'
|
8
8
|
# ORACLE_DB = Sequel.connect('oracle://hr:hr@localhost/XE')
|
9
|
-
POSTGRES_URL = 'postgres:///sequel_test?user=
|
9
|
+
POSTGRES_URL = 'postgres:///sequel_test?user=postgres'
|
10
10
|
# SQLITE_URL = 'sqlite:/'
|
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.4.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: 2009-
|
12
|
+
date: 2009-09-02 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -54,6 +54,7 @@ extra_rdoc_files:
|
|
54
54
|
- doc/release_notes/3.1.0.txt
|
55
55
|
- doc/release_notes/3.2.0.txt
|
56
56
|
- doc/release_notes/3.3.0.txt
|
57
|
+
- doc/release_notes/3.4.0.txt
|
57
58
|
files:
|
58
59
|
- COPYING
|
59
60
|
- CHANGELOG
|
@@ -89,6 +90,7 @@ files:
|
|
89
90
|
- doc/release_notes/3.1.0.txt
|
90
91
|
- doc/release_notes/3.2.0.txt
|
91
92
|
- doc/release_notes/3.3.0.txt
|
93
|
+
- doc/release_notes/3.4.0.txt
|
92
94
|
- doc/schema.rdoc
|
93
95
|
- doc/sharding.rdoc
|
94
96
|
- doc/virtual_rows.rdoc
|
@@ -133,6 +135,10 @@ files:
|
|
133
135
|
- spec/extensions/validation_class_methods_spec.rb
|
134
136
|
- spec/extensions/validation_helpers_spec.rb
|
135
137
|
- spec/extensions/association_proxies_spec.rb
|
138
|
+
- spec/extensions/timestamps_spec.rb
|
139
|
+
- spec/extensions/instance_hooks_spec.rb
|
140
|
+
- spec/extensions/boolean_readers_spec.rb
|
141
|
+
- spec/extensions/nested_attributes_spec.rb
|
136
142
|
- spec/integration
|
137
143
|
- spec/integration/database_test.rb
|
138
144
|
- spec/integration/dataset_test.rb
|
@@ -142,6 +148,7 @@ files:
|
|
142
148
|
- spec/integration/spec_helper.rb
|
143
149
|
- spec/integration/transaction_test.rb
|
144
150
|
- spec/integration/type_test.rb
|
151
|
+
- spec/integration/timezone_test.rb
|
145
152
|
- spec/model
|
146
153
|
- spec/model/association_reflection_spec.rb
|
147
154
|
- spec/model/associations_spec.rb
|
@@ -233,6 +240,7 @@ files:
|
|
233
240
|
- lib/sequel/model/exceptions.rb
|
234
241
|
- lib/sequel/model/inflections.rb
|
235
242
|
- lib/sequel/model/plugins.rb
|
243
|
+
- lib/sequel/model/default_inflections.rb
|
236
244
|
- lib/sequel/plugins
|
237
245
|
- lib/sequel/plugins/caching.rb
|
238
246
|
- lib/sequel/plugins/hook_class_methods.rb
|
@@ -246,6 +254,10 @@ files:
|
|
246
254
|
- lib/sequel/plugins/validation_class_methods.rb
|
247
255
|
- lib/sequel/plugins/validation_helpers.rb
|
248
256
|
- lib/sequel/plugins/association_proxies.rb
|
257
|
+
- lib/sequel/plugins/timestamps.rb
|
258
|
+
- lib/sequel/plugins/boolean_readers.rb
|
259
|
+
- lib/sequel/plugins/instance_hooks.rb
|
260
|
+
- lib/sequel/plugins/nested_attributes.rb
|
249
261
|
- lib/sequel/sql.rb
|
250
262
|
- lib/sequel/version.rb
|
251
263
|
- lib/sequel_core.rb
|