sequel 3.37.0 → 3.38.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 +56 -0
- data/README.rdoc +82 -58
- data/Rakefile +6 -5
- data/bin/sequel +1 -1
- data/doc/active_record.rdoc +67 -52
- data/doc/advanced_associations.rdoc +33 -48
- data/doc/association_basics.rdoc +41 -51
- data/doc/cheat_sheet.rdoc +21 -21
- data/doc/core_extensions.rdoc +374 -0
- data/doc/dataset_basics.rdoc +5 -5
- data/doc/dataset_filtering.rdoc +47 -43
- data/doc/mass_assignment.rdoc +1 -1
- data/doc/migration.rdoc +4 -5
- data/doc/model_hooks.rdoc +3 -3
- data/doc/object_model.rdoc +31 -25
- data/doc/opening_databases.rdoc +19 -5
- data/doc/prepared_statements.rdoc +2 -2
- data/doc/querying.rdoc +109 -52
- data/doc/reflection.rdoc +6 -6
- data/doc/release_notes/3.38.0.txt +234 -0
- data/doc/schema_modification.rdoc +22 -13
- data/doc/sharding.rdoc +8 -9
- data/doc/sql.rdoc +154 -112
- data/doc/testing.rdoc +47 -7
- data/doc/thread_safety.rdoc +1 -1
- data/doc/transactions.rdoc +1 -1
- data/doc/validations.rdoc +1 -1
- data/doc/virtual_rows.rdoc +29 -43
- data/lib/sequel/adapters/do/postgres.rb +1 -4
- data/lib/sequel/adapters/jdbc.rb +14 -3
- data/lib/sequel/adapters/jdbc/db2.rb +9 -0
- data/lib/sequel/adapters/jdbc/derby.rb +41 -4
- data/lib/sequel/adapters/jdbc/jtds.rb +11 -0
- data/lib/sequel/adapters/jdbc/postgresql.rb +3 -6
- data/lib/sequel/adapters/mock.rb +10 -4
- data/lib/sequel/adapters/postgres.rb +1 -28
- data/lib/sequel/adapters/shared/mssql.rb +23 -13
- data/lib/sequel/adapters/shared/postgres.rb +46 -0
- data/lib/sequel/adapters/swift.rb +21 -13
- data/lib/sequel/adapters/swift/mysql.rb +1 -0
- data/lib/sequel/adapters/swift/postgres.rb +4 -5
- data/lib/sequel/adapters/swift/sqlite.rb +2 -1
- data/lib/sequel/adapters/tinytds.rb +14 -2
- data/lib/sequel/adapters/utils/pg_types.rb +5 -0
- data/lib/sequel/core.rb +29 -17
- data/lib/sequel/database/query.rb +1 -1
- data/lib/sequel/database/schema_generator.rb +3 -0
- data/lib/sequel/dataset/actions.rb +5 -6
- data/lib/sequel/dataset/query.rb +7 -7
- data/lib/sequel/dataset/sql.rb +5 -18
- data/lib/sequel/extensions/core_extensions.rb +8 -12
- data/lib/sequel/extensions/pg_array.rb +59 -33
- data/lib/sequel/extensions/pg_array_ops.rb +32 -4
- data/lib/sequel/extensions/pg_auto_parameterize.rb +1 -1
- data/lib/sequel/extensions/pg_hstore.rb +32 -17
- data/lib/sequel/extensions/pg_hstore_ops.rb +32 -3
- data/lib/sequel/extensions/pg_inet.rb +1 -2
- data/lib/sequel/extensions/pg_interval.rb +0 -1
- data/lib/sequel/extensions/pg_json.rb +41 -23
- data/lib/sequel/extensions/pg_range.rb +36 -11
- data/lib/sequel/extensions/pg_range_ops.rb +32 -4
- data/lib/sequel/extensions/pg_row.rb +572 -0
- data/lib/sequel/extensions/pg_row_ops.rb +164 -0
- data/lib/sequel/extensions/query.rb +3 -3
- data/lib/sequel/extensions/schema_dumper.rb +7 -8
- data/lib/sequel/extensions/select_remove.rb +1 -1
- data/lib/sequel/model/base.rb +1 -0
- data/lib/sequel/no_core_ext.rb +1 -1
- data/lib/sequel/plugins/pg_row.rb +121 -0
- data/lib/sequel/plugins/pg_typecast_on_load.rb +65 -0
- data/lib/sequel/plugins/validation_helpers.rb +31 -0
- data/lib/sequel/sql.rb +64 -44
- data/lib/sequel/version.rb +1 -1
- data/spec/adapters/mssql_spec.rb +37 -12
- data/spec/adapters/mysql_spec.rb +39 -75
- data/spec/adapters/oracle_spec.rb +11 -11
- data/spec/adapters/postgres_spec.rb +414 -237
- data/spec/adapters/spec_helper.rb +1 -1
- data/spec/adapters/sqlite_spec.rb +14 -14
- data/spec/core/database_spec.rb +6 -6
- data/spec/core/dataset_spec.rb +169 -205
- data/spec/core/expression_filters_spec.rb +182 -295
- data/spec/core/object_graph_spec.rb +6 -6
- data/spec/core/schema_spec.rb +14 -14
- data/spec/core/spec_helper.rb +1 -0
- data/spec/{extensions/core_extensions_spec.rb → core_extensions_spec.rb} +208 -14
- data/spec/extensions/columns_introspection_spec.rb +5 -5
- data/spec/extensions/hook_class_methods_spec.rb +28 -36
- data/spec/extensions/many_through_many_spec.rb +4 -4
- data/spec/extensions/pg_array_ops_spec.rb +15 -7
- data/spec/extensions/pg_array_spec.rb +81 -48
- data/spec/extensions/pg_auto_parameterize_spec.rb +2 -2
- data/spec/extensions/pg_hstore_ops_spec.rb +13 -9
- data/spec/extensions/pg_hstore_spec.rb +66 -65
- data/spec/extensions/pg_inet_spec.rb +2 -4
- data/spec/extensions/pg_interval_spec.rb +2 -3
- data/spec/extensions/pg_json_spec.rb +20 -18
- data/spec/extensions/pg_range_ops_spec.rb +11 -4
- data/spec/extensions/pg_range_spec.rb +30 -7
- data/spec/extensions/pg_row_ops_spec.rb +48 -0
- data/spec/extensions/pg_row_plugin_spec.rb +45 -0
- data/spec/extensions/pg_row_spec.rb +323 -0
- data/spec/extensions/pg_typecast_on_load_spec.rb +58 -0
- data/spec/extensions/query_literals_spec.rb +11 -11
- data/spec/extensions/query_spec.rb +3 -3
- data/spec/extensions/schema_dumper_spec.rb +20 -4
- data/spec/extensions/schema_spec.rb +18 -41
- data/spec/extensions/select_remove_spec.rb +4 -4
- data/spec/extensions/spec_helper.rb +4 -8
- data/spec/extensions/to_dot_spec.rb +5 -5
- data/spec/extensions/validation_class_methods_spec.rb +28 -16
- data/spec/integration/associations_test.rb +20 -20
- data/spec/integration/dataset_test.rb +98 -98
- data/spec/integration/eager_loader_test.rb +13 -27
- data/spec/integration/plugin_test.rb +5 -5
- data/spec/integration/prepared_statement_test.rb +22 -13
- data/spec/integration/schema_test.rb +28 -18
- data/spec/integration/spec_helper.rb +1 -1
- data/spec/integration/timezone_test.rb +2 -2
- data/spec/integration/type_test.rb +15 -6
- data/spec/model/association_reflection_spec.rb +1 -1
- data/spec/model/associations_spec.rb +4 -4
- data/spec/model/base_spec.rb +5 -5
- data/spec/model/eager_loading_spec.rb +15 -15
- data/spec/model/model_spec.rb +32 -32
- data/spec/model/record_spec.rb +16 -0
- data/spec/model/spec_helper.rb +2 -6
- data/spec/model/validations_spec.rb +1 -1
- metadata +16 -4
|
@@ -179,7 +179,7 @@ describe Sequel::Model, "#eager" do
|
|
|
179
179
|
end
|
|
180
180
|
|
|
181
181
|
it "should handle qualified order clauses when eagerly loading a single one_to_one association using the :correlated_subquery strategy" do
|
|
182
|
-
EagerAlbum.one_to_one :track, :class=>'EagerTrack', :key=>:album_id, :eager_limit_strategy=>:correlated_subquery, :order=>[:tracks__name, :tracks__name
|
|
182
|
+
EagerAlbum.one_to_one :track, :class=>'EagerTrack', :key=>:album_id, :eager_limit_strategy=>:correlated_subquery, :order=>[:tracks__name, Sequel.desc(:tracks__name), Sequel.qualify(:tracks, :name), Sequel.qualify(:t, :name), 1]
|
|
183
183
|
a = EagerAlbum.eager(:track).all
|
|
184
184
|
a.should == [EagerAlbum.load(:id => 1, :band_id => 2)]
|
|
185
185
|
MODEL_DB.sqls.should == ['SELECT * FROM albums', 'SELECT * FROM tracks WHERE ((tracks.album_id IN (1)) AND (tracks.id IN (SELECT t1.id FROM tracks AS t1 WHERE (t1.album_id = tracks.album_id) ORDER BY t1.name, t1.name DESC, t1.name, t.name, 1 LIMIT 1))) ORDER BY tracks.name, tracks.name DESC, tracks.name, t.name, 1']
|
|
@@ -1303,21 +1303,21 @@ describe Sequel::Model, "#eager_graph" do
|
|
|
1303
1303
|
end
|
|
1304
1304
|
|
|
1305
1305
|
it "should respect the association's :graph_block option" do
|
|
1306
|
-
GraphAlbum.many_to_one :active_band, :class=>'GraphBand', :key=>:band_id, :graph_block=>proc{|ja,lja,js| {
|
|
1306
|
+
GraphAlbum.many_to_one :active_band, :class=>'GraphBand', :key=>:band_id, :graph_block=>proc{|ja,lja,js| {Sequel.qualify(ja, :active)=>true}}
|
|
1307
1307
|
GraphAlbum.eager_graph(:active_band).sql.should == "SELECT albums.id, albums.band_id, active_band.id AS active_band_id, active_band.vocalist_id FROM albums LEFT OUTER JOIN bands AS active_band ON ((active_band.id = albums.band_id) AND (active_band.active IS TRUE))"
|
|
1308
1308
|
|
|
1309
|
-
GraphAlbum.one_to_many :right_tracks, :class=>'GraphTrack', :key=>:album_id, :graph_block=>proc{|ja,lja,js| {
|
|
1309
|
+
GraphAlbum.one_to_many :right_tracks, :class=>'GraphTrack', :key=>:album_id, :graph_block=>proc{|ja,lja,js| {Sequel.qualify(ja, :id)=>(0..100)}}
|
|
1310
1310
|
GraphAlbum.eager_graph(:right_tracks).sql.should == 'SELECT albums.id, albums.band_id, right_tracks.id AS right_tracks_id, right_tracks.album_id FROM albums LEFT OUTER JOIN tracks AS right_tracks ON ((right_tracks.album_id = albums.id) AND (right_tracks.id >= 0) AND (right_tracks.id <= 100))'
|
|
1311
1311
|
|
|
1312
|
-
GraphAlbum.many_to_many :active_genres, :class=>'GraphGenre', :left_key=>:album_id, :right_key=>:genre_id, :join_table=>:ag, :graph_block=>proc{|ja,lja,js| {true
|
|
1312
|
+
GraphAlbum.many_to_many :active_genres, :class=>'GraphGenre', :left_key=>:album_id, :right_key=>:genre_id, :join_table=>:ag, :graph_block=>proc{|ja,lja,js| {true=>Sequel.qualify(lja, :active)}}
|
|
1313
1313
|
GraphAlbum.eager_graph(:active_genres).sql.should == "SELECT albums.id, albums.band_id, active_genres.id AS active_genres_id FROM albums LEFT OUTER JOIN ag ON (ag.album_id = albums.id) LEFT OUTER JOIN genres AS active_genres ON ((active_genres.id = ag.genre_id) AND ('t' = ag.active))"
|
|
1314
1314
|
end
|
|
1315
1315
|
|
|
1316
|
-
it "should respect the association's :
|
|
1317
|
-
GraphAlbum.many_to_many :active_genres, :class=>'GraphGenre', :left_key=>:album_id, :right_key=>:genre_id, :join_table=>:ag, :graph_join_table_block=>proc{|ja,lja,js| {
|
|
1316
|
+
it "should respect the association's :graph_join_table_block option" do
|
|
1317
|
+
GraphAlbum.many_to_many :active_genres, :class=>'GraphGenre', :left_key=>:album_id, :right_key=>:genre_id, :join_table=>:ag, :graph_join_table_block=>proc{|ja,lja,js| {Sequel.qualify(ja, :active)=>true}}
|
|
1318
1318
|
GraphAlbum.eager_graph(:active_genres).sql.should == "SELECT albums.id, albums.band_id, active_genres.id AS active_genres_id FROM albums LEFT OUTER JOIN ag ON ((ag.album_id = albums.id) AND (ag.active IS TRUE)) LEFT OUTER JOIN genres AS active_genres ON (active_genres.id = ag.genre_id)"
|
|
1319
1319
|
|
|
1320
|
-
GraphAlbum.many_to_many :active_genres, :class=>'GraphGenre', :left_key=>:album_id, :right_key=>:genre_id, :join_table=>:ag, :graph_block=>proc{|ja,lja,js| {true
|
|
1320
|
+
GraphAlbum.many_to_many :active_genres, :class=>'GraphGenre', :left_key=>:album_id, :right_key=>:genre_id, :join_table=>:ag, :graph_block=>proc{|ja,lja,js| {true=>Sequel.qualify(lja, :active)}}, :graph_join_table_block=>proc{|ja,lja,js| {true=>Sequel.qualify(lja, :active)}}
|
|
1321
1321
|
GraphAlbum.eager_graph(:active_genres).sql.should == "SELECT albums.id, albums.band_id, active_genres.id AS active_genres_id FROM albums LEFT OUTER JOIN ag ON ((ag.album_id = albums.id) AND ('t' = albums.active)) LEFT OUTER JOIN genres AS active_genres ON ((active_genres.id = ag.genre_id) AND ('t' = ag.active))"
|
|
1322
1322
|
end
|
|
1323
1323
|
|
|
@@ -1351,7 +1351,7 @@ describe Sequel::Model, "#eager_graph" do
|
|
|
1351
1351
|
GraphAlbum.many_to_many :active_genres, :class=>'GraphGenre', :left_key=>:album_id, :right_key=>:genre_id, :join_table=>:ag, :graph_join_table_only_conditions=>{:active=>true}
|
|
1352
1352
|
GraphAlbum.eager_graph(:active_genres).sql.should == "SELECT albums.id, albums.band_id, active_genres.id AS active_genres_id FROM albums LEFT OUTER JOIN ag ON (ag.active IS TRUE) LEFT OUTER JOIN genres AS active_genres ON (active_genres.id = ag.genre_id)"
|
|
1353
1353
|
|
|
1354
|
-
GraphAlbum.many_to_many :active_genres, :class=>'GraphGenre', :left_key=>:album_id, :right_key=>:genre_id, :join_table=>:ag, :graph_only_conditions=>(:price + 2 > 100), :graph_join_table_only_conditions=>"active"
|
|
1354
|
+
GraphAlbum.many_to_many :active_genres, :class=>'GraphGenre', :left_key=>:album_id, :right_key=>:genre_id, :join_table=>:ag, :graph_only_conditions=>(Sequel.expr(:price) + 2 > 100), :graph_join_table_only_conditions=>"active"
|
|
1355
1355
|
GraphAlbum.eager_graph(:active_genres).sql.should == "SELECT albums.id, albums.band_id, active_genres.id AS active_genres_id FROM albums LEFT OUTER JOIN ag ON (active) LEFT OUTER JOIN genres AS active_genres ON ((price + 2) > 100)"
|
|
1356
1356
|
end
|
|
1357
1357
|
|
|
@@ -1365,7 +1365,7 @@ describe Sequel::Model, "#eager_graph" do
|
|
|
1365
1365
|
end
|
|
1366
1366
|
|
|
1367
1367
|
it "should only qualify unqualified symbols, identifiers, or ordered versions in association's :order" do
|
|
1368
|
-
GraphAlbum.one_to_many :right_tracks, :class=>'GraphTrack', :key=>:album_id, :order=>[:blah__id.identifier
|
|
1368
|
+
GraphAlbum.one_to_many :right_tracks, :class=>'GraphTrack', :key=>:album_id, :order=>[Sequel.identifier(:blah__id), Sequel.identifier(:blah__id).desc, Sequel.desc(:blah__id), :blah__id, :album_id, Sequel.desc(:album_id), 1, Sequel.lit('RANDOM()'), Sequel.qualify(:b, :a)]
|
|
1369
1369
|
GraphAlbum.eager_graph(:right_tracks).sql.should == 'SELECT albums.id, albums.band_id, right_tracks.id AS right_tracks_id, right_tracks.album_id FROM albums LEFT OUTER JOIN tracks AS right_tracks ON (right_tracks.album_id = albums.id) ORDER BY right_tracks.blah__id, right_tracks.blah__id DESC, blah.id DESC, blah.id, right_tracks.album_id, right_tracks.album_id DESC, 1, RANDOM(), b.a'
|
|
1370
1370
|
end
|
|
1371
1371
|
|
|
@@ -1415,16 +1415,16 @@ describe Sequel::Model, "#eager_graph" do
|
|
|
1415
1415
|
|
|
1416
1416
|
it "should handle eager loading with schemas and aliases of different types" do
|
|
1417
1417
|
GraphAlbum.eager_graph(:band).join(:s__genres, [:b_id]).eager_graph(:genres).sql.should == 'SELECT albums.id, albums.band_id, band.id AS band_id_0, band.vocalist_id, genres_0.id AS genres_0_id FROM albums LEFT OUTER JOIN bands AS band ON (band.id = albums.band_id) INNER JOIN s.genres USING (b_id) LEFT OUTER JOIN ag ON (ag.album_id = albums.id) LEFT OUTER JOIN genres AS genres_0 ON (genres_0.id = ag.genre_id)'
|
|
1418
|
-
GraphAlbum.eager_graph(:band).join(
|
|
1419
|
-
GraphAlbum.eager_graph(:band).join(:s__b.as('genres'), [:b_id]).eager_graph(:genres).sql.should == 'SELECT albums.id, albums.band_id, band.id AS band_id_0, band.vocalist_id, genres_0.id AS genres_0_id FROM albums LEFT OUTER JOIN bands AS band ON (band.id = albums.band_id) INNER JOIN s.b AS genres USING (b_id) LEFT OUTER JOIN ag ON (ag.album_id = albums.id) LEFT OUTER JOIN genres AS genres_0 ON (genres_0.id = ag.genre_id)'
|
|
1420
|
-
GraphAlbum.eager_graph(:band).join(:s__b, [:b_id], :genres
|
|
1421
|
-
GraphAlbum.eager_graph(:band).join(:genres
|
|
1418
|
+
GraphAlbum.eager_graph(:band).join(Sequel.qualify(:s, :genres), [:b_id]).eager_graph(:genres).sql.should == 'SELECT albums.id, albums.band_id, band.id AS band_id_0, band.vocalist_id, genres_0.id AS genres_0_id FROM albums LEFT OUTER JOIN bands AS band ON (band.id = albums.band_id) INNER JOIN s.genres USING (b_id) LEFT OUTER JOIN ag ON (ag.album_id = albums.id) LEFT OUTER JOIN genres AS genres_0 ON (genres_0.id = ag.genre_id)'
|
|
1419
|
+
GraphAlbum.eager_graph(:band).join(Sequel.expr(:s__b).as('genres'), [:b_id]).eager_graph(:genres).sql.should == 'SELECT albums.id, albums.band_id, band.id AS band_id_0, band.vocalist_id, genres_0.id AS genres_0_id FROM albums LEFT OUTER JOIN bands AS band ON (band.id = albums.band_id) INNER JOIN s.b AS genres USING (b_id) LEFT OUTER JOIN ag ON (ag.album_id = albums.id) LEFT OUTER JOIN genres AS genres_0 ON (genres_0.id = ag.genre_id)'
|
|
1420
|
+
GraphAlbum.eager_graph(:band).join(:s__b, [:b_id], Sequel.identifier(:genres)).eager_graph(:genres).sql.should == 'SELECT albums.id, albums.band_id, band.id AS band_id_0, band.vocalist_id, genres_0.id AS genres_0_id FROM albums LEFT OUTER JOIN bands AS band ON (band.id = albums.band_id) INNER JOIN s.b AS genres USING (b_id) LEFT OUTER JOIN ag ON (ag.album_id = albums.id) LEFT OUTER JOIN genres AS genres_0 ON (genres_0.id = ag.genre_id)'
|
|
1421
|
+
GraphAlbum.eager_graph(:band).join(Sequel.identifier(:genres), [:b_id]).eager_graph(:genres).sql.should == 'SELECT albums.id, albums.band_id, band.id AS band_id_0, band.vocalist_id, genres_0.id AS genres_0_id FROM albums LEFT OUTER JOIN bands AS band ON (band.id = albums.band_id) INNER JOIN genres USING (b_id) LEFT OUTER JOIN ag ON (ag.album_id = albums.id) LEFT OUTER JOIN genres AS genres_0 ON (genres_0.id = ag.genre_id)'
|
|
1422
1422
|
GraphAlbum.eager_graph(:band).join('genres', [:b_id]).eager_graph(:genres).sql.should == 'SELECT albums.id, albums.band_id, band.id AS band_id_0, band.vocalist_id, genres_0.id AS genres_0_id FROM albums LEFT OUTER JOIN bands AS band ON (band.id = albums.band_id) INNER JOIN genres USING (b_id) LEFT OUTER JOIN ag ON (ag.album_id = albums.id) LEFT OUTER JOIN genres AS genres_0 ON (genres_0.id = ag.genre_id)'
|
|
1423
1423
|
end
|
|
1424
1424
|
|
|
1425
1425
|
it "should raise errors if invalid aliases or table styles are used" do
|
|
1426
|
-
proc{GraphAlbum.from_self(:alias
|
|
1427
|
-
proc{GraphAlbum.from('?'
|
|
1426
|
+
proc{GraphAlbum.from_self(:alias=>Sequel.qualify(:s, :bands)).eager_graph(:band)}.should raise_error(Sequel::Error)
|
|
1427
|
+
proc{GraphAlbum.from(Sequel.lit('?', :bands)).eager_graph(:band)}.should raise_error(Sequel::Error)
|
|
1428
1428
|
end
|
|
1429
1429
|
|
|
1430
1430
|
it "should eagerly load schema qualified tables correctly with joins" do
|
data/spec/model/model_spec.rb
CHANGED
|
@@ -20,35 +20,35 @@ describe "Sequel::Model()" do
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
it "should return a model subclass with a dataset with the default database and given table name if given a LiteralString" do
|
|
23
|
-
c = Sequel::Model('blah'
|
|
23
|
+
c = Sequel::Model(Sequel.lit('blah'))
|
|
24
24
|
c.superclass.should == Sequel::Model
|
|
25
25
|
c.db.should == @db
|
|
26
|
-
c.table_name.should == 'blah'
|
|
26
|
+
c.table_name.should == Sequel.lit('blah')
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
it "should return a model subclass with a dataset with the default database and given table name if given an SQL::Identifier" do
|
|
30
|
-
c = Sequel::Model(:blah
|
|
30
|
+
c = Sequel::Model(Sequel.identifier(:blah))
|
|
31
31
|
c.superclass.should == Sequel::Model
|
|
32
32
|
c.db.should == @db
|
|
33
|
-
c.table_name.should == :blah
|
|
33
|
+
c.table_name.should == Sequel.identifier(:blah)
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
it "should return a model subclass with a dataset with the default database and given table name if given an SQL::QualifiedIdentifier" do
|
|
37
|
-
c = Sequel::Model(
|
|
37
|
+
c = Sequel::Model(Sequel.qualify(:boo, :blah))
|
|
38
38
|
c.superclass.should == Sequel::Model
|
|
39
39
|
c.db.should == @db
|
|
40
|
-
c.table_name.should ==
|
|
40
|
+
c.table_name.should == Sequel.qualify(:boo, :blah)
|
|
41
41
|
end
|
|
42
42
|
|
|
43
43
|
it "should return a model subclass with a dataset with the default database and given table name if given an SQL::AliasedExpression" do
|
|
44
|
-
c = Sequel::Model(
|
|
44
|
+
c = Sequel::Model(Sequel.as(:blah, :boo))
|
|
45
45
|
c.superclass.should == Sequel::Model
|
|
46
46
|
c.db.should == @db
|
|
47
47
|
c.table_name.should == :boo
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
it "should return a model subclass with the given dataset if given a dataset using an SQL::Identifier" do
|
|
51
|
-
ds = @db[:blah
|
|
51
|
+
ds = @db[Sequel.identifier(:blah)]
|
|
52
52
|
c = Sequel::Model(ds)
|
|
53
53
|
c.superclass.should == Sequel::Model
|
|
54
54
|
c.dataset.should == ds
|
|
@@ -84,29 +84,29 @@ describe "Sequel::Model()" do
|
|
|
84
84
|
|
|
85
85
|
it "should work without raising an exception with an SQL::Identifier " do
|
|
86
86
|
proc do
|
|
87
|
-
class ::Album < Sequel::Model(:table
|
|
88
|
-
class ::Album < Sequel::Model(:table
|
|
87
|
+
class ::Album < Sequel::Model(Sequel.identifier(:table)); end
|
|
88
|
+
class ::Album < Sequel::Model(Sequel.identifier(:table)); end
|
|
89
89
|
end.should_not raise_error
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
it "should work without raising an exception with an SQL::QualifiedIdentifier " do
|
|
93
93
|
proc do
|
|
94
|
-
class ::Album < Sequel::Model(
|
|
95
|
-
class ::Album < Sequel::Model(
|
|
94
|
+
class ::Album < Sequel::Model(Sequel.qualify(:schema, :table)); end
|
|
95
|
+
class ::Album < Sequel::Model(Sequel.qualify(:schema, :table)); end
|
|
96
96
|
end.should_not raise_error
|
|
97
97
|
end
|
|
98
98
|
|
|
99
99
|
it "should work without raising an exception with an SQL::AliasedExpression" do
|
|
100
100
|
proc do
|
|
101
|
-
class ::Album < Sequel::Model(
|
|
102
|
-
class ::Album < Sequel::Model(
|
|
101
|
+
class ::Album < Sequel::Model(Sequel.as(:table, :alias)); end
|
|
102
|
+
class ::Album < Sequel::Model(Sequel.as(:table, :alias)); end
|
|
103
103
|
end.should_not raise_error
|
|
104
104
|
end
|
|
105
105
|
|
|
106
106
|
it "should work without raising an exception with an LiteralString" do
|
|
107
107
|
proc do
|
|
108
|
-
class ::Album < Sequel::Model('table'
|
|
109
|
-
class ::Album < Sequel::Model('table'
|
|
108
|
+
class ::Album < Sequel::Model(Sequel.lit('table')); end
|
|
109
|
+
class ::Album < Sequel::Model(Sequel.lit('table')); end
|
|
110
110
|
end.should_not raise_error
|
|
111
111
|
end
|
|
112
112
|
|
|
@@ -126,16 +126,16 @@ describe "Sequel::Model()" do
|
|
|
126
126
|
|
|
127
127
|
it "should work without raising an exception with a dataset with an SQL::Identifier" do
|
|
128
128
|
proc do
|
|
129
|
-
class ::Album < Sequel::Model(@db[:table
|
|
130
|
-
class ::Album < Sequel::Model(@db[:table
|
|
129
|
+
class ::Album < Sequel::Model(@db[Sequel.identifier(:table)]); end
|
|
130
|
+
class ::Album < Sequel::Model(@db[Sequel.identifier(:table)]); end
|
|
131
131
|
end.should_not raise_error
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
it "should raise an exception if anonymous model caching is disabled" do
|
|
135
135
|
Sequel::Model.cache_anonymous_models = false
|
|
136
136
|
proc do
|
|
137
|
-
class ::Album < Sequel::Model(@db[:table
|
|
138
|
-
class ::Album < Sequel::Model(@db[:table
|
|
137
|
+
class ::Album < Sequel::Model(@db[Sequel.identifier(:table)]); end
|
|
138
|
+
class ::Album < Sequel::Model(@db[Sequel.identifier(:table)]); end
|
|
139
139
|
end.should raise_error
|
|
140
140
|
end
|
|
141
141
|
end
|
|
@@ -195,25 +195,25 @@ describe Sequel::Model, "dataset & schema" do
|
|
|
195
195
|
|
|
196
196
|
it "set_dataset should take a LiteralString" do
|
|
197
197
|
@model.db = MODEL_DB
|
|
198
|
-
@model.set_dataset('foo'
|
|
199
|
-
@model.table_name.should == 'foo'
|
|
198
|
+
@model.set_dataset(Sequel.lit('foo'))
|
|
199
|
+
@model.table_name.should == Sequel.lit('foo')
|
|
200
200
|
end
|
|
201
201
|
|
|
202
202
|
it "set_dataset should take an SQL::Identifier" do
|
|
203
203
|
@model.db = MODEL_DB
|
|
204
|
-
@model.set_dataset(:foo
|
|
205
|
-
@model.table_name.should == :foo
|
|
204
|
+
@model.set_dataset(Sequel.identifier(:foo))
|
|
205
|
+
@model.table_name.should == Sequel.identifier(:foo)
|
|
206
206
|
end
|
|
207
207
|
|
|
208
208
|
it "set_dataset should take an SQL::QualifiedIdentifier" do
|
|
209
209
|
@model.db = MODEL_DB
|
|
210
|
-
@model.set_dataset(
|
|
211
|
-
@model.table_name.should ==
|
|
210
|
+
@model.set_dataset(Sequel.qualify(:bar, :foo))
|
|
211
|
+
@model.table_name.should == Sequel.qualify(:bar, :foo)
|
|
212
212
|
end
|
|
213
213
|
|
|
214
214
|
it "set_dataset should take an SQL::AliasedExpression" do
|
|
215
215
|
@model.db = MODEL_DB
|
|
216
|
-
@model.set_dataset(
|
|
216
|
+
@model.set_dataset(Sequel.as(:foo, :bar))
|
|
217
217
|
@model.table_name.should == :bar
|
|
218
218
|
end
|
|
219
219
|
|
|
@@ -361,12 +361,12 @@ describe Sequel::Model, ".subset" do
|
|
|
361
361
|
specify "should create a filter on the underlying dataset" do
|
|
362
362
|
proc {@c.new_only}.should raise_error(NoMethodError)
|
|
363
363
|
|
|
364
|
-
@c.subset(:new_only)
|
|
364
|
+
@c.subset(:new_only){age < 'new'}
|
|
365
365
|
|
|
366
366
|
@c.new_only.sql.should == "SELECT * FROM items WHERE (age < 'new')"
|
|
367
367
|
@c.dataset.new_only.sql.should == "SELECT * FROM items WHERE (age < 'new')"
|
|
368
368
|
|
|
369
|
-
@c.subset(:pricey)
|
|
369
|
+
@c.subset(:pricey){price > 100}
|
|
370
370
|
|
|
371
371
|
@c.pricey.sql.should == "SELECT * FROM items WHERE (price > 100)"
|
|
372
372
|
@c.dataset.pricey.sql.should == "SELECT * FROM items WHERE (price > 100)"
|
|
@@ -393,15 +393,15 @@ describe Sequel::Model, ".find" do
|
|
|
393
393
|
@c.find(:name => 'sharon').should be_a_kind_of(@c)
|
|
394
394
|
MODEL_DB.sqls.should == ["SELECT * FROM items WHERE (name = 'sharon') LIMIT 1"]
|
|
395
395
|
|
|
396
|
-
@c.find(:name.like('abc%')).should be_a_kind_of(@c)
|
|
396
|
+
@c.find(Sequel.expr(:name).like('abc%')).should be_a_kind_of(@c)
|
|
397
397
|
MODEL_DB.sqls.should == ["SELECT * FROM items WHERE (name LIKE 'abc%') LIMIT 1"]
|
|
398
398
|
end
|
|
399
399
|
|
|
400
400
|
specify "should accept filter blocks" do
|
|
401
|
-
@c.find{
|
|
401
|
+
@c.find{id > 1}.should be_a_kind_of(@c)
|
|
402
402
|
MODEL_DB.sqls.should == ["SELECT * FROM items WHERE (id > 1) LIMIT 1"]
|
|
403
403
|
|
|
404
|
-
@c.find
|
|
404
|
+
@c.find{(x > 1) & (y < 2)}.should be_a_kind_of(@c)
|
|
405
405
|
MODEL_DB.sqls.should == ["SELECT * FROM items WHERE ((x > 1) AND (y < 2)) LIMIT 1"]
|
|
406
406
|
end
|
|
407
407
|
end
|
data/spec/model/record_spec.rb
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
require File.join(File.dirname(File.expand_path(__FILE__)), "spec_helper")
|
|
2
2
|
|
|
3
|
+
describe "Model#values" do
|
|
4
|
+
before do
|
|
5
|
+
@c = Class.new(Sequel::Model(:items))
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "should return the hash of model values" do
|
|
9
|
+
hash = {:x=>1}
|
|
10
|
+
@c.load(hash).values.should equal(hash)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it "should be aliased as to_hash" do
|
|
14
|
+
hash = {:x=>1}
|
|
15
|
+
@c.load(hash).to_hash.should equal(hash)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
3
19
|
describe "Model#save server use" do
|
|
4
20
|
before do
|
|
5
21
|
@db = Sequel.mock(:autoid=>proc{|sql| 10}, :fetch=>{:x=>1, :id=>10}, :servers=>{:blah=>{}, :read_only=>{}})
|
data/spec/model/spec_helper.rb
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
require 'rubygems'
|
|
2
|
-
unless Object.const_defined?('Sequel')
|
|
2
|
+
unless Object.const_defined?('Sequel') && Sequel.const_defined?('Model')
|
|
3
3
|
$:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../../lib/"))
|
|
4
|
-
require 'sequel/
|
|
5
|
-
end
|
|
6
|
-
unless Sequel.const_defined?('Model')
|
|
7
|
-
$:.unshift(File.join(File.dirname(File.expand_path(__FILE__)), "../../lib/"))
|
|
8
|
-
require 'sequel/model'
|
|
4
|
+
require 'sequel/no_core_ext'
|
|
9
5
|
end
|
|
10
6
|
|
|
11
7
|
if ENV['SEQUEL_COLUMNS_INTROSPECTION']
|
|
@@ -65,7 +65,7 @@ describe Sequel::Model::Errors do
|
|
|
65
65
|
@errors.full_messages.should == []
|
|
66
66
|
|
|
67
67
|
@errors[:blow] << 'blieuh'
|
|
68
|
-
@errors[:blow] << 'blich'
|
|
68
|
+
@errors[:blow] << Sequel.lit('blich')
|
|
69
69
|
@errors[:blay] << 'bliu'
|
|
70
70
|
msgs = @errors.full_messages
|
|
71
71
|
msgs.size.should == 3
|
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.38.0
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-
|
|
12
|
+
date: 2012-08-01 00:00:00.000000000 Z
|
|
13
13
|
dependencies: []
|
|
14
14
|
description: The Database Toolkit for Ruby
|
|
15
15
|
email: code@jeremyevans.net
|
|
@@ -42,6 +42,7 @@ extra_rdoc_files:
|
|
|
42
42
|
- doc/transactions.rdoc
|
|
43
43
|
- doc/thread_safety.rdoc
|
|
44
44
|
- doc/object_model.rdoc
|
|
45
|
+
- doc/core_extensions.rdoc
|
|
45
46
|
- doc/release_notes/1.0.txt
|
|
46
47
|
- doc/release_notes/1.1.txt
|
|
47
48
|
- doc/release_notes/1.3.txt
|
|
@@ -98,6 +99,7 @@ extra_rdoc_files:
|
|
|
98
99
|
- doc/release_notes/3.35.0.txt
|
|
99
100
|
- doc/release_notes/3.36.0.txt
|
|
100
101
|
- doc/release_notes/3.37.0.txt
|
|
102
|
+
- doc/release_notes/3.38.0.txt
|
|
101
103
|
files:
|
|
102
104
|
- MIT-LICENSE
|
|
103
105
|
- CHANGELOG
|
|
@@ -172,6 +174,7 @@ files:
|
|
|
172
174
|
- doc/release_notes/3.35.0.txt
|
|
173
175
|
- doc/release_notes/3.36.0.txt
|
|
174
176
|
- doc/release_notes/3.37.0.txt
|
|
177
|
+
- doc/release_notes/3.38.0.txt
|
|
175
178
|
- doc/sharding.rdoc
|
|
176
179
|
- doc/sql.rdoc
|
|
177
180
|
- doc/validations.rdoc
|
|
@@ -182,6 +185,7 @@ files:
|
|
|
182
185
|
- doc/transactions.rdoc
|
|
183
186
|
- doc/thread_safety.rdoc
|
|
184
187
|
- doc/object_model.rdoc
|
|
188
|
+
- doc/core_extensions.rdoc
|
|
185
189
|
- spec/adapters/firebird_spec.rb
|
|
186
190
|
- spec/adapters/informix_spec.rb
|
|
187
191
|
- spec/adapters/mssql_spec.rb
|
|
@@ -276,7 +280,6 @@ files:
|
|
|
276
280
|
- spec/extensions/query_literals_spec.rb
|
|
277
281
|
- spec/extensions/dirty_spec.rb
|
|
278
282
|
- spec/extensions/pg_json_spec.rb
|
|
279
|
-
- spec/extensions/core_extensions_spec.rb
|
|
280
283
|
- spec/extensions/pg_inet_spec.rb
|
|
281
284
|
- spec/extensions/eval_inspect_spec.rb
|
|
282
285
|
- spec/extensions/pg_range_spec.rb
|
|
@@ -284,6 +287,10 @@ files:
|
|
|
284
287
|
- spec/extensions/pg_range_ops_spec.rb
|
|
285
288
|
- spec/extensions/pg_interval_spec.rb
|
|
286
289
|
- spec/extensions/columns_introspection_spec.rb
|
|
290
|
+
- spec/extensions/pg_row_ops_spec.rb
|
|
291
|
+
- spec/extensions/pg_row_plugin_spec.rb
|
|
292
|
+
- spec/extensions/pg_row_spec.rb
|
|
293
|
+
- spec/extensions/pg_typecast_on_load_spec.rb
|
|
287
294
|
- spec/integration/associations_test.rb
|
|
288
295
|
- spec/integration/database_test.rb
|
|
289
296
|
- spec/integration/dataset_test.rb
|
|
@@ -356,6 +363,7 @@ files:
|
|
|
356
363
|
- spec/files/transaction_specified_migrations/002_create_basic.rb
|
|
357
364
|
- spec/files/transaction_unspecified_migrations/001_create_alt_basic.rb
|
|
358
365
|
- spec/files/transaction_unspecified_migrations/002_create_basic.rb
|
|
366
|
+
- spec/core_extensions_spec.rb
|
|
359
367
|
- lib/sequel.rb
|
|
360
368
|
- lib/sequel/adapters/ado.rb
|
|
361
369
|
- lib/sequel/adapters/ado/mssql.rb
|
|
@@ -475,6 +483,8 @@ files:
|
|
|
475
483
|
- lib/sequel/extensions/split_array_nil.rb
|
|
476
484
|
- lib/sequel/extensions/pg_range_ops.rb
|
|
477
485
|
- lib/sequel/extensions/pg_interval.rb
|
|
486
|
+
- lib/sequel/extensions/pg_row.rb
|
|
487
|
+
- lib/sequel/extensions/pg_row_ops.rb
|
|
478
488
|
- lib/sequel/metaprogramming.rb
|
|
479
489
|
- lib/sequel/model.rb
|
|
480
490
|
- lib/sequel/model/associations.rb
|
|
@@ -532,6 +542,8 @@ files:
|
|
|
532
542
|
- lib/sequel/plugins/many_to_one_pk_lookup.rb
|
|
533
543
|
- lib/sequel/plugins/dirty.rb
|
|
534
544
|
- lib/sequel/plugins/eager_each.rb
|
|
545
|
+
- lib/sequel/plugins/pg_row.rb
|
|
546
|
+
- lib/sequel/plugins/pg_typecast_on_load.rb
|
|
535
547
|
- lib/sequel/timezones.rb
|
|
536
548
|
- lib/sequel/version.rb
|
|
537
549
|
- lib/sequel/ast_transformer.rb
|
|
@@ -565,7 +577,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
565
577
|
version: '0'
|
|
566
578
|
requirements: []
|
|
567
579
|
rubyforge_project: sequel
|
|
568
|
-
rubygems_version: 1.8.
|
|
580
|
+
rubygems_version: 1.8.23
|
|
569
581
|
signing_key:
|
|
570
582
|
specification_version: 3
|
|
571
583
|
summary: The Database Toolkit for Ruby
|