sequel 3.29.0 → 3.30.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +35 -3
- data/Rakefile +2 -1
- data/doc/association_basics.rdoc +11 -0
- data/doc/opening_databases.rdoc +2 -0
- data/doc/release_notes/3.30.0.txt +135 -0
- data/doc/testing.rdoc +17 -3
- data/lib/sequel/adapters/amalgalite.rb +2 -2
- data/lib/sequel/adapters/do/mysql.rb +5 -2
- data/lib/sequel/adapters/ibmdb.rb +2 -2
- data/lib/sequel/adapters/jdbc.rb +126 -43
- data/lib/sequel/adapters/jdbc/as400.rb +11 -3
- data/lib/sequel/adapters/jdbc/db2.rb +2 -1
- data/lib/sequel/adapters/jdbc/derby.rb +44 -19
- data/lib/sequel/adapters/jdbc/h2.rb +32 -19
- data/lib/sequel/adapters/jdbc/hsqldb.rb +21 -17
- data/lib/sequel/adapters/jdbc/jtds.rb +9 -4
- data/lib/sequel/adapters/jdbc/mssql.rb +3 -1
- data/lib/sequel/adapters/jdbc/mysql.rb +2 -1
- data/lib/sequel/adapters/jdbc/oracle.rb +21 -7
- data/lib/sequel/adapters/jdbc/postgresql.rb +3 -2
- data/lib/sequel/adapters/jdbc/sqlite.rb +2 -1
- data/lib/sequel/adapters/jdbc/sqlserver.rb +48 -18
- data/lib/sequel/adapters/mock.rb +2 -1
- data/lib/sequel/adapters/mysql.rb +4 -2
- data/lib/sequel/adapters/mysql2.rb +2 -2
- data/lib/sequel/adapters/odbc/mssql.rb +1 -1
- data/lib/sequel/adapters/openbase.rb +1 -1
- data/lib/sequel/adapters/oracle.rb +6 -6
- data/lib/sequel/adapters/postgres.rb +25 -12
- data/lib/sequel/adapters/shared/access.rb +14 -6
- data/lib/sequel/adapters/shared/db2.rb +36 -13
- data/lib/sequel/adapters/shared/firebird.rb +12 -5
- data/lib/sequel/adapters/shared/informix.rb +11 -3
- data/lib/sequel/adapters/shared/mssql.rb +94 -47
- data/lib/sequel/adapters/shared/mysql.rb +107 -49
- data/lib/sequel/adapters/shared/mysql_prepared_statements.rb +2 -2
- data/lib/sequel/adapters/shared/oracle.rb +54 -27
- data/lib/sequel/adapters/shared/postgres.rb +65 -26
- data/lib/sequel/adapters/shared/progress.rb +4 -1
- data/lib/sequel/adapters/shared/sqlite.rb +36 -20
- data/lib/sequel/adapters/sqlite.rb +2 -3
- data/lib/sequel/adapters/swift/mysql.rb +3 -2
- data/lib/sequel/adapters/swift/sqlite.rb +2 -2
- data/lib/sequel/adapters/tinytds.rb +14 -8
- data/lib/sequel/adapters/utils/emulate_offset_with_row_number.rb +7 -4
- data/lib/sequel/database/misc.rb +6 -2
- data/lib/sequel/dataset/graph.rb +33 -7
- data/lib/sequel/dataset/prepared_statements.rb +19 -5
- data/lib/sequel/dataset/sql.rb +611 -201
- data/lib/sequel/model/associations.rb +12 -5
- data/lib/sequel/model/base.rb +20 -5
- data/lib/sequel/plugins/sharding.rb +9 -29
- data/lib/sequel/sql.rb +2 -1
- data/lib/sequel/timezones.rb +14 -4
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/mysql_spec.rb +10 -0
- data/spec/adapters/oracle_spec.rb +1 -1
- data/spec/core/core_sql_spec.rb +3 -1
- data/spec/core/database_spec.rb +42 -0
- data/spec/core/dataset_spec.rb +10 -3
- data/spec/core/mock_adapter_spec.rb +4 -0
- data/spec/core/object_graph_spec.rb +38 -0
- data/spec/extensions/association_autoreloading_spec.rb +1 -10
- data/spec/extensions/association_dependencies_spec.rb +2 -12
- data/spec/extensions/association_pks_spec.rb +35 -39
- data/spec/extensions/caching_spec.rb +23 -50
- data/spec/extensions/class_table_inheritance_spec.rb +30 -82
- data/spec/extensions/composition_spec.rb +18 -13
- data/spec/extensions/hook_class_methods_spec.rb +65 -91
- data/spec/extensions/identity_map_spec.rb +33 -103
- data/spec/extensions/instance_filters_spec.rb +10 -21
- data/spec/extensions/instance_hooks_spec.rb +6 -24
- data/spec/extensions/json_serializer_spec.rb +4 -5
- data/spec/extensions/lazy_attributes_spec.rb +16 -20
- data/spec/extensions/list_spec.rb +17 -39
- data/spec/extensions/many_through_many_spec.rb +135 -277
- data/spec/extensions/migration_spec.rb +18 -15
- data/spec/extensions/named_timezones_spec.rb +1 -1
- data/spec/extensions/nested_attributes_spec.rb +97 -92
- data/spec/extensions/optimistic_locking_spec.rb +9 -20
- data/spec/extensions/prepared_statements_associations_spec.rb +22 -37
- data/spec/extensions/prepared_statements_safe_spec.rb +9 -27
- data/spec/extensions/prepared_statements_spec.rb +11 -30
- data/spec/extensions/prepared_statements_with_pk_spec.rb +6 -13
- data/spec/extensions/pretty_table_spec.rb +1 -6
- data/spec/extensions/rcte_tree_spec.rb +41 -43
- data/spec/extensions/schema_dumper_spec.rb +3 -6
- data/spec/extensions/serialization_spec.rb +20 -32
- data/spec/extensions/sharding_spec.rb +66 -140
- data/spec/extensions/single_table_inheritance_spec.rb +14 -36
- data/spec/extensions/spec_helper.rb +10 -64
- data/spec/extensions/sql_expr_spec.rb +20 -60
- data/spec/extensions/tactical_eager_loading_spec.rb +9 -19
- data/spec/extensions/timestamps_spec.rb +6 -6
- data/spec/extensions/to_dot_spec.rb +1 -2
- data/spec/extensions/touch_spec.rb +13 -14
- data/spec/extensions/tree_spec.rb +11 -26
- data/spec/extensions/update_primary_key_spec.rb +30 -24
- data/spec/extensions/validation_class_methods_spec.rb +30 -51
- data/spec/extensions/validation_helpers_spec.rb +16 -35
- data/spec/integration/dataset_test.rb +16 -4
- data/spec/integration/prepared_statement_test.rb +4 -2
- data/spec/model/eager_loading_spec.rb +16 -0
- data/spec/model/model_spec.rb +15 -1
- data/spec/model/record_spec.rb +60 -0
- metadata +23 -40
@@ -740,6 +740,14 @@ describe Sequel::Model, "#eager_graph" do
|
|
740
740
|
ds.all.should == [GraphAlbum.load(:id=>1, :band_id=>2, :band_id_0=>2, :vocalist_id=>3)]
|
741
741
|
end
|
742
742
|
|
743
|
+
it "should not modify existing dataset" do
|
744
|
+
ds1 = GraphAlbum.dataset
|
745
|
+
ds2 = ds1.eager_graph(:band)
|
746
|
+
proc{ds1.eager_graph(:band)}.should_not raise_error
|
747
|
+
proc{ds2.eager_graph(:tracks)}.should_not raise_error
|
748
|
+
proc{ds2.eager_graph(:tracks)}.should_not raise_error
|
749
|
+
end
|
750
|
+
|
743
751
|
it "should eagerly load a single many_to_one association" do
|
744
752
|
ds = GraphAlbum.eager_graph(:band)
|
745
753
|
ds.sql.should == 'SELECT albums.id, albums.band_id, band.id AS band_id_0, band.vocalist_id FROM albums LEFT OUTER JOIN bands AS band ON (band.id = albums.band_id)'
|
@@ -1081,6 +1089,14 @@ describe Sequel::Model, "#eager_graph" do
|
|
1081
1089
|
GraphAlbum.eager_graph(:inner_genres).sql.should == 'SELECT albums.id, albums.band_id FROM albums LEFT OUTER JOIN ag ON (ag.album_id = albums.id) LEFT OUTER JOIN genres AS inner_genres ON (inner_genres.id = ag.genre_id)'
|
1082
1090
|
end
|
1083
1091
|
|
1092
|
+
it "should respect the association's :graph_alias_base option" do
|
1093
|
+
GraphAlbum.many_to_one :inner_band, :class=>'GraphBand', :key=>:band_id, :graph_alias_base=>:foo
|
1094
|
+
ds = GraphAlbum.eager_graph(:inner_band)
|
1095
|
+
ds.sql.should == 'SELECT albums.id, albums.band_id, foo.id AS foo_id, foo.vocalist_id FROM albums LEFT OUTER JOIN bands AS foo ON (foo.id = albums.band_id)'
|
1096
|
+
GraphAlbum.one_to_many :right_tracks, :class=>'GraphTrack', :key=>:album_id, :graph_alias_base=>:foo
|
1097
|
+
ds.eager_graph(:right_tracks).sql.should == 'SELECT albums.id, albums.band_id, foo.id AS foo_id, foo.vocalist_id, foo_0.id AS foo_0_id, foo_0.album_id FROM albums LEFT OUTER JOIN bands AS foo ON (foo.id = albums.band_id) LEFT OUTER JOIN tracks AS foo_0 ON (foo_0.album_id = albums.id)'
|
1098
|
+
end
|
1099
|
+
|
1084
1100
|
it "should respect the association's :graph_join_type option" do
|
1085
1101
|
GraphAlbum.many_to_one :inner_band, :class=>'GraphBand', :key=>:band_id, :graph_join_type=>:inner
|
1086
1102
|
GraphAlbum.eager_graph(:inner_band).sql.should == 'SELECT albums.id, albums.band_id, inner_band.id AS inner_band_id, inner_band.vocalist_id FROM albums INNER JOIN bands AS inner_band ON (inner_band.id = albums.band_id)'
|
data/spec/model/model_spec.rb
CHANGED
@@ -214,11 +214,25 @@ describe Sequel::Model, "dataset & schema" do
|
|
214
214
|
proc{@model.set_dataset(Object.new)}.should raise_error(Sequel::Error)
|
215
215
|
end
|
216
216
|
|
217
|
-
it "set_dataset should add the destroy method to the dataset" do
|
217
|
+
it "set_dataset should add the destroy method to the dataset that destroys each object" do
|
218
218
|
ds = MODEL_DB[:foo]
|
219
219
|
ds.should_not respond_to(:destroy)
|
220
220
|
@model.set_dataset(ds)
|
221
221
|
ds.should respond_to(:destroy)
|
222
|
+
MODEL_DB.sqls
|
223
|
+
ds._fetch = [{:id=>1}, {:id=>2}]
|
224
|
+
ds.destroy.should == 2
|
225
|
+
MODEL_DB.sqls.should == ["SELECT * FROM foo", "DELETE FROM foo WHERE (id = 1)", "DELETE FROM foo WHERE (id = 2)"]
|
226
|
+
end
|
227
|
+
|
228
|
+
it "set_dataset should add the destroy method that respects sharding with transactions" do
|
229
|
+
db = Sequel.mock(:servers=>{:s1=>{}})
|
230
|
+
ds = db[:foo].server(:s1)
|
231
|
+
@model.use_transactions = true
|
232
|
+
@model.set_dataset(ds)
|
233
|
+
db.sqls
|
234
|
+
ds.destroy.should == 0
|
235
|
+
db.sqls.should == ["BEGIN -- s1", "SELECT * FROM foo -- s1", "COMMIT -- s1"]
|
222
236
|
end
|
223
237
|
|
224
238
|
it "should raise an error on set_dataset if there is an error connecting to the database" do
|
data/spec/model/record_spec.rb
CHANGED
@@ -270,6 +270,66 @@ describe "Model#save" do
|
|
270
270
|
proc { o.save(:y) }.should raise_error(Sequel::Rollback)
|
271
271
|
MODEL_DB.sqls.should == []
|
272
272
|
end
|
273
|
+
|
274
|
+
it "should support a :server option to set the server/shard to use" do
|
275
|
+
db = Sequel.mock(:fetch=>{:id=>13, :x=>1}, :autoid=>proc{13}, :numrows=>1, :servers=>{:s1=>{}})
|
276
|
+
c = Class.new(Sequel::Model(db[:items]))
|
277
|
+
c.columns :id, :x
|
278
|
+
db.sqls
|
279
|
+
o = c.new(:x => 1)
|
280
|
+
o.save(:server=>:s1)
|
281
|
+
db.sqls.should == ["INSERT INTO items (x) VALUES (1) -- s1", "SELECT * FROM items WHERE (id = 13) LIMIT 1 -- s1"]
|
282
|
+
o.save(:server=>:s1, :transaction=>true)
|
283
|
+
db.sqls.should == ["BEGIN -- s1", "UPDATE items SET x = 1 WHERE (id = 13) -- s1", 'COMMIT -- s1']
|
284
|
+
end
|
285
|
+
end
|
286
|
+
|
287
|
+
describe "Model#set_server" do
|
288
|
+
before do
|
289
|
+
@db = Sequel.mock(:fetch=>{:id=>13, :x=>1}, :autoid=>proc{13}, :numrows=>1, :servers=>{:s1=>{}})
|
290
|
+
@c = Class.new(Sequel::Model(@db[:items])) do
|
291
|
+
columns :id, :x
|
292
|
+
end
|
293
|
+
@db.sqls
|
294
|
+
end
|
295
|
+
|
296
|
+
it "should set the server to use when inserting" do
|
297
|
+
@c.new(:x => 1).set_server(:s1).save
|
298
|
+
@db.sqls.should == ["INSERT INTO items (x) VALUES (1) -- s1", "SELECT * FROM items WHERE (id = 13) LIMIT 1 -- s1"]
|
299
|
+
end
|
300
|
+
|
301
|
+
it "should set the server to use when updating" do
|
302
|
+
@c.load(:id=>13, :x => 1).set_server(:s1).save
|
303
|
+
@db.sqls.should == ["UPDATE items SET x = 1 WHERE (id = 13) -- s1"]
|
304
|
+
end
|
305
|
+
|
306
|
+
it "should set the server to use for transactions when saving" do
|
307
|
+
@c.load(:id=>13, :x => 1).set_server(:s1).save(:transaction=>true)
|
308
|
+
@db.sqls.should == ["BEGIN -- s1", "UPDATE items SET x = 1 WHERE (id = 13) -- s1", 'COMMIT -- s1']
|
309
|
+
end
|
310
|
+
|
311
|
+
it "should set the server to use when deleting" do
|
312
|
+
@c.load(:id=>13).set_server(:s1).delete
|
313
|
+
@db.sqls.should == ["DELETE FROM items WHERE (id = 13) -- s1"]
|
314
|
+
end
|
315
|
+
|
316
|
+
it "should set the server to use for transactions when destroying" do
|
317
|
+
o = @c.load(:id=>13).set_server(:s1)
|
318
|
+
o.use_transactions = true
|
319
|
+
o.destroy
|
320
|
+
@db.sqls.should == ["BEGIN -- s1", "DELETE FROM items WHERE (id = 13) -- s1", 'COMMIT -- s1']
|
321
|
+
end
|
322
|
+
|
323
|
+
it "should set the server on this if this is already loaded" do
|
324
|
+
o = @c.load(:id=>13, :x => 1)
|
325
|
+
o.this
|
326
|
+
o.set_server(:s1)
|
327
|
+
o.this.opts[:server].should == :s1
|
328
|
+
end
|
329
|
+
|
330
|
+
it "should set the server on this if this is not already loaded" do
|
331
|
+
@c.load(:id=>13, :x => 1).set_server(:s1).this.opts[:server].should == :s1
|
332
|
+
end
|
273
333
|
end
|
274
334
|
|
275
335
|
describe "Model#marshallable" do
|
metadata
CHANGED
@@ -1,30 +1,22 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: sequel
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 3.30.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 3
|
8
|
-
- 29
|
9
|
-
- 0
|
10
|
-
version: 3.29.0
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Jeremy Evans
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2011-11-01 00:00:00 Z
|
12
|
+
date: 2011-12-01 00:00:00.000000000 Z
|
19
13
|
dependencies: []
|
20
|
-
|
21
14
|
description: The Database Toolkit for Ruby
|
22
15
|
email: code@jeremyevans.net
|
23
|
-
executables:
|
16
|
+
executables:
|
24
17
|
- sequel
|
25
18
|
extensions: []
|
26
|
-
|
27
|
-
extra_rdoc_files:
|
19
|
+
extra_rdoc_files:
|
28
20
|
- README.rdoc
|
29
21
|
- CHANGELOG
|
30
22
|
- MIT-LICENSE
|
@@ -96,7 +88,8 @@ extra_rdoc_files:
|
|
96
88
|
- doc/release_notes/3.27.0.txt
|
97
89
|
- doc/release_notes/3.28.0.txt
|
98
90
|
- doc/release_notes/3.29.0.txt
|
99
|
-
|
91
|
+
- doc/release_notes/3.30.0.txt
|
92
|
+
files:
|
100
93
|
- MIT-LICENSE
|
101
94
|
- CHANGELOG
|
102
95
|
- README.rdoc
|
@@ -162,6 +155,7 @@ files:
|
|
162
155
|
- doc/release_notes/3.27.0.txt
|
163
156
|
- doc/release_notes/3.28.0.txt
|
164
157
|
- doc/release_notes/3.29.0.txt
|
158
|
+
- doc/release_notes/3.30.0.txt
|
165
159
|
- doc/sharding.rdoc
|
166
160
|
- doc/sql.rdoc
|
167
161
|
- doc/validations.rdoc
|
@@ -475,44 +469,33 @@ files:
|
|
475
469
|
- lib/sequel_model.rb
|
476
470
|
homepage: http://sequel.rubyforge.org
|
477
471
|
licenses: []
|
478
|
-
|
479
472
|
post_install_message:
|
480
|
-
rdoc_options:
|
473
|
+
rdoc_options:
|
481
474
|
- --quiet
|
482
475
|
- --line-numbers
|
483
476
|
- --inline-source
|
484
477
|
- --title
|
485
|
-
-
|
478
|
+
- ! 'Sequel: The Database Toolkit for Ruby'
|
486
479
|
- --main
|
487
480
|
- README.rdoc
|
488
|
-
require_paths:
|
481
|
+
require_paths:
|
489
482
|
- lib
|
490
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
483
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
491
484
|
none: false
|
492
|
-
requirements:
|
493
|
-
- -
|
494
|
-
- !ruby/object:Gem::Version
|
495
|
-
hash: 63
|
496
|
-
segments:
|
497
|
-
- 1
|
498
|
-
- 8
|
499
|
-
- 4
|
485
|
+
requirements:
|
486
|
+
- - ! '>='
|
487
|
+
- !ruby/object:Gem::Version
|
500
488
|
version: 1.8.4
|
501
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
489
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
502
490
|
none: false
|
503
|
-
requirements:
|
504
|
-
- -
|
505
|
-
- !ruby/object:Gem::Version
|
506
|
-
|
507
|
-
segments:
|
508
|
-
- 0
|
509
|
-
version: "0"
|
491
|
+
requirements:
|
492
|
+
- - ! '>='
|
493
|
+
- !ruby/object:Gem::Version
|
494
|
+
version: '0'
|
510
495
|
requirements: []
|
511
|
-
|
512
496
|
rubyforge_project: sequel
|
513
|
-
rubygems_version: 1.8.
|
497
|
+
rubygems_version: 1.8.11
|
514
498
|
signing_key:
|
515
499
|
specification_version: 3
|
516
500
|
summary: The Database Toolkit for Ruby
|
517
501
|
test_files: []
|
518
|
-
|