colincasey-sequel 2.10.0 → 2.10.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +7 -1
- data/doc/advanced_associations.rdoc +614 -0
- data/doc/cheat_sheet.rdoc +223 -0
- data/doc/dataset_filtering.rdoc +158 -0
- data/doc/prepared_statements.rdoc +104 -0
- data/doc/release_notes/1.0.txt +38 -0
- data/doc/release_notes/1.1.txt +143 -0
- data/doc/release_notes/1.3.txt +101 -0
- data/doc/release_notes/1.4.0.txt +53 -0
- data/doc/release_notes/1.5.0.txt +155 -0
- data/doc/release_notes/2.0.0.txt +298 -0
- data/doc/release_notes/2.1.0.txt +271 -0
- data/doc/release_notes/2.10.0.txt +328 -0
- data/doc/release_notes/2.2.0.txt +253 -0
- data/doc/release_notes/2.3.0.txt +88 -0
- data/doc/release_notes/2.4.0.txt +106 -0
- data/doc/release_notes/2.5.0.txt +137 -0
- data/doc/release_notes/2.6.0.txt +157 -0
- data/doc/release_notes/2.7.0.txt +166 -0
- data/doc/release_notes/2.8.0.txt +171 -0
- data/doc/release_notes/2.9.0.txt +97 -0
- data/doc/schema.rdoc +29 -0
- data/doc/sharding.rdoc +113 -0
- data/lib/sequel.rb +1 -0
- data/lib/sequel_core/adapters/ado.rb +89 -0
- data/lib/sequel_core/adapters/db2.rb +143 -0
- data/lib/sequel_core/adapters/dbi.rb +112 -0
- data/lib/sequel_core/adapters/do/mysql.rb +38 -0
- data/lib/sequel_core/adapters/do/postgres.rb +92 -0
- data/lib/sequel_core/adapters/do/sqlite.rb +31 -0
- data/lib/sequel_core/adapters/do.rb +205 -0
- data/lib/sequel_core/adapters/firebird.rb +298 -0
- data/lib/sequel_core/adapters/informix.rb +85 -0
- data/lib/sequel_core/adapters/jdbc/h2.rb +69 -0
- data/lib/sequel_core/adapters/jdbc/mysql.rb +66 -0
- data/lib/sequel_core/adapters/jdbc/oracle.rb +23 -0
- data/lib/sequel_core/adapters/jdbc/postgresql.rb +113 -0
- data/lib/sequel_core/adapters/jdbc/sqlite.rb +43 -0
- data/lib/sequel_core/adapters/jdbc.rb +491 -0
- data/lib/sequel_core/adapters/mysql.rb +369 -0
- data/lib/sequel_core/adapters/odbc.rb +174 -0
- data/lib/sequel_core/adapters/openbase.rb +68 -0
- data/lib/sequel_core/adapters/oracle.rb +107 -0
- data/lib/sequel_core/adapters/postgres.rb +456 -0
- data/lib/sequel_core/adapters/shared/ms_access.rb +110 -0
- data/lib/sequel_core/adapters/shared/mssql.rb +102 -0
- data/lib/sequel_core/adapters/shared/mysql.rb +325 -0
- data/lib/sequel_core/adapters/shared/oracle.rb +61 -0
- data/lib/sequel_core/adapters/shared/postgres.rb +715 -0
- data/lib/sequel_core/adapters/shared/progress.rb +31 -0
- data/lib/sequel_core/adapters/shared/sqlite.rb +265 -0
- data/lib/sequel_core/adapters/sqlite.rb +248 -0
- data/lib/sequel_core/connection_pool.rb +258 -0
- data/lib/sequel_core/core_ext.rb +217 -0
- data/lib/sequel_core/core_sql.rb +202 -0
- data/lib/sequel_core/database/schema.rb +164 -0
- data/lib/sequel_core/database.rb +691 -0
- data/lib/sequel_core/dataset/callback.rb +13 -0
- data/lib/sequel_core/dataset/convenience.rb +237 -0
- data/lib/sequel_core/dataset/pagination.rb +96 -0
- data/lib/sequel_core/dataset/prepared_statements.rb +220 -0
- data/lib/sequel_core/dataset/query.rb +41 -0
- data/lib/sequel_core/dataset/schema.rb +15 -0
- data/lib/sequel_core/dataset/sql.rb +1010 -0
- data/lib/sequel_core/dataset/stored_procedures.rb +75 -0
- data/lib/sequel_core/dataset/unsupported.rb +43 -0
- data/lib/sequel_core/dataset.rb +511 -0
- data/lib/sequel_core/deprecated.rb +26 -0
- data/lib/sequel_core/exceptions.rb +44 -0
- data/lib/sequel_core/migration.rb +212 -0
- data/lib/sequel_core/object_graph.rb +230 -0
- data/lib/sequel_core/pretty_table.rb +71 -0
- data/lib/sequel_core/schema/generator.rb +320 -0
- data/lib/sequel_core/schema/sql.rb +325 -0
- data/lib/sequel_core/schema.rb +2 -0
- data/lib/sequel_core/sql.rb +887 -0
- data/lib/sequel_core/version.rb +11 -0
- data/lib/sequel_core.rb +172 -0
- data/lib/sequel_model/association_reflection.rb +267 -0
- data/lib/sequel_model/associations.rb +499 -0
- data/lib/sequel_model/base.rb +523 -0
- data/lib/sequel_model/caching.rb +82 -0
- data/lib/sequel_model/dataset_methods.rb +26 -0
- data/lib/sequel_model/eager_loading.rb +370 -0
- data/lib/sequel_model/exceptions.rb +7 -0
- data/lib/sequel_model/hooks.rb +101 -0
- data/lib/sequel_model/inflector.rb +281 -0
- data/lib/sequel_model/plugins.rb +62 -0
- data/lib/sequel_model/record.rb +568 -0
- data/lib/sequel_model/schema.rb +49 -0
- data/lib/sequel_model/validations.rb +429 -0
- data/lib/sequel_model.rb +91 -0
- data/spec/adapters/ado_spec.rb +46 -0
- data/spec/adapters/firebird_spec.rb +376 -0
- data/spec/adapters/informix_spec.rb +96 -0
- data/spec/adapters/mysql_spec.rb +881 -0
- data/spec/adapters/oracle_spec.rb +244 -0
- data/spec/adapters/postgres_spec.rb +687 -0
- data/spec/adapters/spec_helper.rb +10 -0
- data/spec/adapters/sqlite_spec.rb +555 -0
- data/spec/integration/dataset_test.rb +134 -0
- data/spec/integration/eager_loader_test.rb +696 -0
- data/spec/integration/prepared_statement_test.rb +130 -0
- data/spec/integration/schema_test.rb +180 -0
- data/spec/integration/spec_helper.rb +58 -0
- data/spec/integration/type_test.rb +96 -0
- data/spec/rcov.opts +6 -0
- data/spec/sequel_core/connection_pool_spec.rb +526 -0
- data/spec/sequel_core/core_ext_spec.rb +156 -0
- data/spec/sequel_core/core_sql_spec.rb +522 -0
- data/spec/sequel_core/database_spec.rb +1188 -0
- data/spec/sequel_core/dataset_spec.rb +3481 -0
- data/spec/sequel_core/expression_filters_spec.rb +363 -0
- data/spec/sequel_core/migration_spec.rb +261 -0
- data/spec/sequel_core/object_graph_spec.rb +272 -0
- data/spec/sequel_core/pretty_table_spec.rb +58 -0
- data/spec/sequel_core/schema_generator_spec.rb +167 -0
- data/spec/sequel_core/schema_spec.rb +780 -0
- data/spec/sequel_core/spec_helper.rb +55 -0
- data/spec/sequel_core/version_spec.rb +7 -0
- data/spec/sequel_model/association_reflection_spec.rb +93 -0
- data/spec/sequel_model/associations_spec.rb +1767 -0
- data/spec/sequel_model/base_spec.rb +419 -0
- data/spec/sequel_model/caching_spec.rb +215 -0
- data/spec/sequel_model/dataset_methods_spec.rb +78 -0
- data/spec/sequel_model/eager_loading_spec.rb +1165 -0
- data/spec/sequel_model/hooks_spec.rb +485 -0
- data/spec/sequel_model/inflector_spec.rb +119 -0
- data/spec/sequel_model/model_spec.rb +588 -0
- data/spec/sequel_model/plugins_spec.rb +80 -0
- data/spec/sequel_model/record_spec.rb +1184 -0
- data/spec/sequel_model/schema_spec.rb +90 -0
- data/spec/sequel_model/spec_helper.rb +78 -0
- data/spec/sequel_model/validations_spec.rb +1067 -0
- data/spec/spec.opts +0 -0
- data/spec/spec_config.rb.example +10 -0
- metadata +177 -3
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
unless Object.const_defined?('Sequel')
|
3
|
+
$:.unshift(File.join(File.dirname(__FILE__), "../../lib/"))
|
4
|
+
require 'sequel_core'
|
5
|
+
end
|
6
|
+
|
7
|
+
class MockDataset < Sequel::Dataset
|
8
|
+
def insert(*args)
|
9
|
+
@db.execute insert_sql(*args)
|
10
|
+
end
|
11
|
+
|
12
|
+
def update(*args)
|
13
|
+
@db.execute update_sql(*args)
|
14
|
+
end
|
15
|
+
|
16
|
+
def fetch_rows(sql)
|
17
|
+
@db.execute(sql)
|
18
|
+
yield({:id => 1, :x => 1})
|
19
|
+
end
|
20
|
+
|
21
|
+
def quoted_identifier(c)
|
22
|
+
"\"#{c}\""
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
class MockDatabase < Sequel::Database
|
27
|
+
@@quote_identifiers = false
|
28
|
+
self.identifier_input_method = nil
|
29
|
+
self.identifier_output_method = nil
|
30
|
+
attr_reader :sqls
|
31
|
+
|
32
|
+
def execute(sql, opts={})
|
33
|
+
@sqls ||= []
|
34
|
+
@sqls << sql
|
35
|
+
end
|
36
|
+
|
37
|
+
def reset
|
38
|
+
@sqls = []
|
39
|
+
end
|
40
|
+
|
41
|
+
def transaction; yield; end
|
42
|
+
|
43
|
+
def dataset; MockDataset.new(self); end
|
44
|
+
end
|
45
|
+
|
46
|
+
class SchemaDummyDatabase < Sequel::Database
|
47
|
+
attr_reader :sqls
|
48
|
+
self.identifier_input_method = nil
|
49
|
+
self.identifier_output_method = nil
|
50
|
+
|
51
|
+
def execute(sql, opts={})
|
52
|
+
@sqls ||= []
|
53
|
+
@sqls << sql
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "spec_helper")
|
2
|
+
|
3
|
+
describe Sequel::Model::Associations::AssociationReflection, "#associated_class" do
|
4
|
+
before do
|
5
|
+
@c = Class.new(Sequel::Model)
|
6
|
+
class ::ParParent < Sequel::Model; end
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should use the :class value if present" do
|
10
|
+
@c.many_to_one :c, :class=>ParParent
|
11
|
+
@c.association_reflection(:c).keys.should include(:class)
|
12
|
+
@c.association_reflection(:c).associated_class.should == ParParent
|
13
|
+
end
|
14
|
+
it "should figure out the class if the :class value is not present" do
|
15
|
+
@c.many_to_one :c, :class=>'ParParent'
|
16
|
+
@c.association_reflection(:c).keys.should_not include(:class)
|
17
|
+
@c.association_reflection(:c).associated_class.should == ParParent
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
describe Sequel::Model::Associations::AssociationReflection, "#primary_key" do
|
22
|
+
before do
|
23
|
+
@c = Class.new(Sequel::Model)
|
24
|
+
class ::ParParent < Sequel::Model; end
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should use the :primary_key value if present" do
|
28
|
+
@c.many_to_one :c, :class=>ParParent, :primary_key=>:blah__blah
|
29
|
+
@c.association_reflection(:c).keys.should include(:primary_key)
|
30
|
+
@c.association_reflection(:c).primary_key.should == :blah__blah
|
31
|
+
end
|
32
|
+
it "should use the associated table's primary key if :primary_key is not present" do
|
33
|
+
@c.many_to_one :c, :class=>'ParParent'
|
34
|
+
@c.association_reflection(:c).keys.should_not include(:primary_key)
|
35
|
+
@c.association_reflection(:c).primary_key.should == :id
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe Sequel::Model::Associations::AssociationReflection, "#reciprocal" do
|
40
|
+
it "should use the :reciprocal value if present" do
|
41
|
+
@c = Class.new(Sequel::Model)
|
42
|
+
@d = Class.new(Sequel::Model)
|
43
|
+
@c.many_to_one :c, :class=>@d, :reciprocal=>:xx
|
44
|
+
@c.association_reflection(:c).keys.should include(:reciprocal)
|
45
|
+
@c.association_reflection(:c).reciprocal.should == :xx
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should figure out the reciprocal if the :reciprocal value is not present" do
|
49
|
+
class ::ParParent < Sequel::Model; end
|
50
|
+
class ::ParParentTwo < Sequel::Model; end
|
51
|
+
class ::ParParentThree < Sequel::Model; end
|
52
|
+
ParParent.many_to_one :par_parent_two
|
53
|
+
ParParentTwo.one_to_many :par_parents
|
54
|
+
ParParent.many_to_many :par_parent_threes
|
55
|
+
ParParentThree.many_to_many :par_parents
|
56
|
+
|
57
|
+
ParParent.association_reflection(:par_parent_two).keys.should_not include(:reciprocal)
|
58
|
+
ParParent.association_reflection(:par_parent_two).reciprocal.should == :par_parents
|
59
|
+
ParParentTwo.association_reflection(:par_parents).keys.should_not include(:reciprocal)
|
60
|
+
ParParentTwo.association_reflection(:par_parents).reciprocal.should == :par_parent_two
|
61
|
+
ParParent.association_reflection(:par_parent_threes).keys.should_not include(:reciprocal)
|
62
|
+
ParParent.association_reflection(:par_parent_threes).reciprocal.should == :par_parents
|
63
|
+
ParParentThree.association_reflection(:par_parents).keys.should_not include(:reciprocal)
|
64
|
+
ParParentThree.association_reflection(:par_parents).reciprocal.should == :par_parent_threes
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
describe Sequel::Model::Associations::AssociationReflection, "#select" do
|
69
|
+
before do
|
70
|
+
@c = Class.new(Sequel::Model)
|
71
|
+
class ::ParParent < Sequel::Model; end
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should use the :select value if present" do
|
75
|
+
@c.many_to_one :c, :class=>ParParent, :select=>[:par_parents__id]
|
76
|
+
@c.association_reflection(:c).keys.should include(:select)
|
77
|
+
@c.association_reflection(:c).select.should == [:par_parents__id]
|
78
|
+
end
|
79
|
+
it "should be the associated_table.* if :select is not present for a many_to_many associaiton" do
|
80
|
+
@c.many_to_many :cs, :class=>'ParParent'
|
81
|
+
@c.association_reflection(:cs).keys.should_not include(:select)
|
82
|
+
@c.association_reflection(:cs).select.should == :par_parents.*
|
83
|
+
end
|
84
|
+
it "should be if :select is not present for a many_to_one and one_to_many associaiton" do
|
85
|
+
@c.one_to_many :cs, :class=>'ParParent'
|
86
|
+
@c.association_reflection(:cs).keys.should_not include(:select)
|
87
|
+
@c.association_reflection(:cs).select.should == nil
|
88
|
+
@c.many_to_one :c, :class=>'ParParent'
|
89
|
+
@c.association_reflection(:c).keys.should_not include(:select)
|
90
|
+
@c.association_reflection(:c).select.should == nil
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|