composite_primary_keys 7.0.16 → 8.0.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.
- checksums.yaml +4 -4
- data/History.rdoc +600 -623
- data/lib/composite_primary_keys.rb +113 -115
- data/lib/composite_primary_keys/associations/association.rb +23 -23
- data/lib/composite_primary_keys/associations/association_scope.rb +73 -77
- data/lib/composite_primary_keys/associations/collection_association.rb +15 -0
- data/lib/composite_primary_keys/associations/has_many_association.rb +69 -56
- data/lib/composite_primary_keys/associations/has_many_through_association.rb +30 -28
- data/lib/composite_primary_keys/associations/join_dependency.rb +87 -89
- data/lib/composite_primary_keys/associations/join_dependency/join_association.rb +22 -22
- data/lib/composite_primary_keys/associations/preloader/association.rb +90 -78
- data/lib/composite_primary_keys/associations/preloader/belongs_to.rb +19 -19
- data/lib/composite_primary_keys/associations/singular_association.rb +15 -0
- data/lib/composite_primary_keys/attribute_methods.rb +9 -0
- data/lib/composite_primary_keys/attribute_methods/dirty.rb +29 -26
- data/lib/composite_primary_keys/attribute_methods/read.rb +19 -34
- data/lib/composite_primary_keys/attribute_methods/write.rb +30 -36
- data/lib/composite_primary_keys/attribute_set/builder.rb +20 -0
- data/lib/composite_primary_keys/base.rb +135 -129
- data/lib/composite_primary_keys/composite_arrays.rb +30 -30
- data/lib/composite_primary_keys/composite_predicates.rb +50 -50
- data/lib/composite_primary_keys/composite_relation.rb +48 -48
- data/lib/composite_primary_keys/connection_adapters/abstract/connection_specification_changes.rb +2 -4
- data/lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb +46 -60
- data/lib/composite_primary_keys/core.rb +69 -47
- data/lib/composite_primary_keys/fixtures.rb +22 -22
- data/lib/composite_primary_keys/persistence.rb +56 -60
- data/lib/composite_primary_keys/relation.rb +68 -56
- data/lib/composite_primary_keys/relation/calculations.rb +79 -75
- data/lib/composite_primary_keys/relation/finder_methods.rb +175 -196
- data/lib/composite_primary_keys/relation/query_methods.rb +40 -40
- data/lib/composite_primary_keys/sanitization.rb +52 -52
- data/lib/composite_primary_keys/validations/uniqueness.rb +36 -37
- data/lib/composite_primary_keys/version.rb +8 -8
- data/tasks/databases/oracle.rake +25 -25
- data/tasks/databases/sqlserver.rake +27 -40
- data/test/abstract_unit.rb +113 -113
- data/test/connections/databases.ci.yml +15 -15
- data/test/connections/databases.example.yml +18 -18
- data/test/connections/native_oracle/connection.rb +11 -11
- data/test/connections/native_oracle_enhanced/connection.rb +16 -16
- data/test/connections/native_sqlserver/connection.rb +11 -14
- data/test/fixtures/comment.rb +7 -7
- data/test/fixtures/db_definitions/db2-create-tables.sql +125 -126
- data/test/fixtures/db_definitions/db2-drop-tables.sql +18 -18
- data/test/fixtures/db_definitions/mysql.sql +207 -208
- data/test/fixtures/db_definitions/oracle.drop.sql +45 -45
- data/test/fixtures/db_definitions/oracle.sql +222 -223
- data/test/fixtures/db_definitions/postgresql.sql +209 -210
- data/test/fixtures/db_definitions/sqlite.sql +196 -197
- data/test/fixtures/db_definitions/sqlserver.drop.sql +91 -94
- data/test/fixtures/db_definitions/sqlserver.sql +225 -232
- data/test/fixtures/dorm.rb +2 -2
- data/test/fixtures/employee.rb +5 -5
- data/test/fixtures/membership.rb +6 -6
- data/test/fixtures/membership_statuses.yml +16 -16
- data/test/fixtures/memberships.yml +10 -10
- data/test/fixtures/product_tariffs.yml +14 -14
- data/test/fixtures/reference_code.rb +7 -7
- data/test/fixtures/restaurants_suburb.rb +2 -2
- data/test/fixtures/suburb.rb +5 -5
- data/test/fixtures/topic.rb +5 -5
- data/test/fixtures/topic_source.rb +6 -6
- data/test/fixtures/topic_sources.yml +3 -3
- data/test/fixtures/topics.yml +8 -8
- data/test/fixtures/users.yml +10 -10
- data/test/test_associations.rb +295 -275
- data/test/test_attribute_methods.rb +63 -63
- data/test/test_attributes.rb +60 -60
- data/test/test_calculations.rb +37 -42
- data/test/test_callbacks.rb +99 -99
- data/test/test_create.rb +112 -112
- data/test/test_delete.rb +148 -152
- data/test/test_delete_all.rb +28 -26
- data/test/test_dumpable.rb +15 -15
- data/test/test_enum.rb +21 -20
- data/test/test_equal.rb +26 -26
- data/test/test_find.rb +118 -118
- data/test/test_habtm.rb +113 -113
- data/test/test_nested_attributes.rb +124 -124
- data/test/test_polymorphic.rb +26 -26
- data/test/test_predicates.rb +40 -40
- data/test/test_santiago.rb +23 -23
- data/test/test_suite.rb +33 -34
- data/test/test_touch.rb +23 -23
- data/test/test_tutorial_example.rb +21 -21
- data/test/test_update.rb +71 -71
- metadata +9 -13
- data/lib/composite_primary_keys/arel/visitors/to_sql.rb +0 -20
- data/lib/composite_primary_keys/associations/has_and_belongs_to_many_association.rb +0 -59
- data/lib/composite_primary_keys/associations/join_dependency/join_part.rb +0 -39
- data/lib/composite_primary_keys/associations/preloader/has_and_belongs_to_many.rb +0 -46
- data/lib/composite_primary_keys/connection_adapters/sqlserver_adapter.rb +0 -17
- data/lib/composite_primary_keys/locking/optimistic.rb +0 -55
- data/test/test_optimistic.rb +0 -18
@@ -1,124 +1,124 @@
|
|
1
|
-
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
-
|
3
|
-
# Testing the find action on composite ActiveRecords with two primary keys
|
4
|
-
class TestNestedAttributes < ActiveSupport::TestCase
|
5
|
-
fixtures :reference_types, :reference_codes
|
6
|
-
|
7
|
-
def test_nested_atttribute_create
|
8
|
-
code_id = 1001
|
9
|
-
|
10
|
-
reference_type = reference_types(:name_prefix)
|
11
|
-
reference_type.update_attribute :reference_codes_attributes, [{
|
12
|
-
:reference_code => code_id,
|
13
|
-
:code_label => 'XX',
|
14
|
-
:abbreviation => 'Xx'
|
15
|
-
}]
|
16
|
-
assert_not_nil ReferenceCode.find_by_reference_code(code_id)
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_nested_atttribute_update
|
20
|
-
code_id = 1002
|
21
|
-
|
22
|
-
reference_type = reference_types(:name_prefix)
|
23
|
-
reference_type.update_attribute :reference_codes_attributes, [{
|
24
|
-
:reference_code => code_id,
|
25
|
-
:code_label => 'XX',
|
26
|
-
:abbreviation => 'Xx'
|
27
|
-
}]
|
28
|
-
|
29
|
-
reference_code = ReferenceCode.find_by_reference_code(code_id)
|
30
|
-
cpk = CompositePrimaryKeys::CompositeKeys[reference_type.reference_type_id, code_id]
|
31
|
-
reference_type.update_attribute :reference_codes_attributes, [{
|
32
|
-
:id => cpk,
|
33
|
-
:code_label => 'AAA',
|
34
|
-
:abbreviation => 'Aaa'
|
35
|
-
}]
|
36
|
-
|
37
|
-
reference_code = ReferenceCode.find_by_reference_code(code_id)
|
38
|
-
assert_kind_of(ReferenceCode, reference_code)
|
39
|
-
assert_equal(reference_code.code_label, 'AAA')
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_nested_atttribute_update_2
|
43
|
-
reference_type = reference_types(:gender)
|
44
|
-
reference_code = reference_codes(:gender_male)
|
45
|
-
|
46
|
-
reference_type.update_attributes(:reference_codes_attributes => [{:id => reference_code.id,
|
47
|
-
:code_label => 'XX',
|
48
|
-
:abbreviation => 'Xx'}])
|
49
|
-
|
50
|
-
reference_code.reload
|
51
|
-
assert_equal(reference_code.code_label, 'XX')
|
52
|
-
assert_equal(reference_code.abbreviation, 'Xx')
|
53
|
-
end
|
54
|
-
|
55
|
-
def test_nested_atttribute_update_3
|
56
|
-
reference_type = reference_types(:gender)
|
57
|
-
reference_code = reference_codes(:gender_male)
|
58
|
-
|
59
|
-
reference_type.update_attributes(:reference_codes_attributes => [{:id => reference_code.id.to_s,
|
60
|
-
:code_label => 'XX',
|
61
|
-
:abbreviation => 'Xx'}])
|
62
|
-
|
63
|
-
reference_code.reload
|
64
|
-
assert_equal(reference_code.code_label, 'XX')
|
65
|
-
assert_equal(reference_code.abbreviation, 'Xx')
|
66
|
-
end
|
67
|
-
|
68
|
-
fixtures :topics, :topic_sources
|
69
|
-
|
70
|
-
def test_nested_attributes_create_with_string_in_primary_key
|
71
|
-
platform = 'instagram'
|
72
|
-
|
73
|
-
topic = topics(:music)
|
74
|
-
topic.update_attribute :topic_sources_attributes, [{
|
75
|
-
:platform => platform,
|
76
|
-
:keywords => 'funk'
|
77
|
-
}]
|
78
|
-
assert_not_nil TopicSource.find_by_platform(platform)
|
79
|
-
end
|
80
|
-
|
81
|
-
def test_nested_attributes_update_with_string_in_primary_key
|
82
|
-
platform = 'instagram'
|
83
|
-
|
84
|
-
topic = topics(:music)
|
85
|
-
topic.update_attribute :topic_sources_attributes, [{
|
86
|
-
:platform => platform,
|
87
|
-
:keywords => 'funk'
|
88
|
-
}]
|
89
|
-
assert_not_nil TopicSource.find_by_platform(platform)
|
90
|
-
|
91
|
-
topic_source = TopicSource.find_by_platform(platform)
|
92
|
-
cpk = CompositePrimaryKeys::CompositeKeys[topic.id, platform]
|
93
|
-
topic.update_attribute :topic_sources_attributes, [{
|
94
|
-
:id => cpk,
|
95
|
-
:keywords => 'jazz'
|
96
|
-
}]
|
97
|
-
|
98
|
-
topic_source = TopicSource.find_by_platform(platform)
|
99
|
-
assert_kind_of(TopicSource, topic_source)
|
100
|
-
assert_equal(topic_source.keywords, 'jazz')
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_nested_attributes_update_with_string_in_primary_key_2
|
104
|
-
topic = topics(:music)
|
105
|
-
topic_source = topic_sources(:music_source)
|
106
|
-
|
107
|
-
topic.update_attributes(:topic_sources_attributes => [{:id => topic_source.id,
|
108
|
-
:keywords => 'classical, jazz'}])
|
109
|
-
|
110
|
-
topic_source.reload
|
111
|
-
assert_equal(topic_source.keywords, 'classical, jazz')
|
112
|
-
end
|
113
|
-
|
114
|
-
def test_nested_attributes_update_with_string_in_primary_key_3
|
115
|
-
topic = topics(:music)
|
116
|
-
topic_source = topic_sources(:music_source)
|
117
|
-
|
118
|
-
topic.update_attributes(:topic_sources_attributes => [{:id => topic_source.id.to_s,
|
119
|
-
:keywords => 'classical, jazz'}])
|
120
|
-
|
121
|
-
topic_source.reload
|
122
|
-
assert_equal(topic_source.keywords, 'classical, jazz')
|
123
|
-
end
|
124
|
-
end
|
1
|
+
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
+
|
3
|
+
# Testing the find action on composite ActiveRecords with two primary keys
|
4
|
+
class TestNestedAttributes < ActiveSupport::TestCase
|
5
|
+
fixtures :reference_types, :reference_codes
|
6
|
+
|
7
|
+
def test_nested_atttribute_create
|
8
|
+
code_id = 1001
|
9
|
+
|
10
|
+
reference_type = reference_types(:name_prefix)
|
11
|
+
reference_type.update_attribute :reference_codes_attributes, [{
|
12
|
+
:reference_code => code_id,
|
13
|
+
:code_label => 'XX',
|
14
|
+
:abbreviation => 'Xx'
|
15
|
+
}]
|
16
|
+
assert_not_nil ReferenceCode.find_by_reference_code(code_id)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_nested_atttribute_update
|
20
|
+
code_id = 1002
|
21
|
+
|
22
|
+
reference_type = reference_types(:name_prefix)
|
23
|
+
reference_type.update_attribute :reference_codes_attributes, [{
|
24
|
+
:reference_code => code_id,
|
25
|
+
:code_label => 'XX',
|
26
|
+
:abbreviation => 'Xx'
|
27
|
+
}]
|
28
|
+
|
29
|
+
reference_code = ReferenceCode.find_by_reference_code(code_id)
|
30
|
+
cpk = CompositePrimaryKeys::CompositeKeys[reference_type.reference_type_id, code_id]
|
31
|
+
reference_type.update_attribute :reference_codes_attributes, [{
|
32
|
+
:id => cpk,
|
33
|
+
:code_label => 'AAA',
|
34
|
+
:abbreviation => 'Aaa'
|
35
|
+
}]
|
36
|
+
|
37
|
+
reference_code = ReferenceCode.find_by_reference_code(code_id)
|
38
|
+
assert_kind_of(ReferenceCode, reference_code)
|
39
|
+
assert_equal(reference_code.code_label, 'AAA')
|
40
|
+
end
|
41
|
+
|
42
|
+
def test_nested_atttribute_update_2
|
43
|
+
reference_type = reference_types(:gender)
|
44
|
+
reference_code = reference_codes(:gender_male)
|
45
|
+
|
46
|
+
reference_type.update_attributes(:reference_codes_attributes => [{:id => reference_code.id,
|
47
|
+
:code_label => 'XX',
|
48
|
+
:abbreviation => 'Xx'}])
|
49
|
+
|
50
|
+
reference_code.reload
|
51
|
+
assert_equal(reference_code.code_label, 'XX')
|
52
|
+
assert_equal(reference_code.abbreviation, 'Xx')
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_nested_atttribute_update_3
|
56
|
+
reference_type = reference_types(:gender)
|
57
|
+
reference_code = reference_codes(:gender_male)
|
58
|
+
|
59
|
+
reference_type.update_attributes(:reference_codes_attributes => [{:id => reference_code.id.to_s,
|
60
|
+
:code_label => 'XX',
|
61
|
+
:abbreviation => 'Xx'}])
|
62
|
+
|
63
|
+
reference_code.reload
|
64
|
+
assert_equal(reference_code.code_label, 'XX')
|
65
|
+
assert_equal(reference_code.abbreviation, 'Xx')
|
66
|
+
end
|
67
|
+
|
68
|
+
fixtures :topics, :topic_sources
|
69
|
+
|
70
|
+
def test_nested_attributes_create_with_string_in_primary_key
|
71
|
+
platform = 'instagram'
|
72
|
+
|
73
|
+
topic = topics(:music)
|
74
|
+
topic.update_attribute :topic_sources_attributes, [{
|
75
|
+
:platform => platform,
|
76
|
+
:keywords => 'funk'
|
77
|
+
}]
|
78
|
+
assert_not_nil TopicSource.find_by_platform(platform)
|
79
|
+
end
|
80
|
+
|
81
|
+
def test_nested_attributes_update_with_string_in_primary_key
|
82
|
+
platform = 'instagram'
|
83
|
+
|
84
|
+
topic = topics(:music)
|
85
|
+
topic.update_attribute :topic_sources_attributes, [{
|
86
|
+
:platform => platform,
|
87
|
+
:keywords => 'funk'
|
88
|
+
}]
|
89
|
+
assert_not_nil TopicSource.find_by_platform(platform)
|
90
|
+
|
91
|
+
topic_source = TopicSource.find_by_platform(platform)
|
92
|
+
cpk = CompositePrimaryKeys::CompositeKeys[topic.id, platform]
|
93
|
+
topic.update_attribute :topic_sources_attributes, [{
|
94
|
+
:id => cpk,
|
95
|
+
:keywords => 'jazz'
|
96
|
+
}]
|
97
|
+
|
98
|
+
topic_source = TopicSource.find_by_platform(platform)
|
99
|
+
assert_kind_of(TopicSource, topic_source)
|
100
|
+
assert_equal(topic_source.keywords, 'jazz')
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_nested_attributes_update_with_string_in_primary_key_2
|
104
|
+
topic = topics(:music)
|
105
|
+
topic_source = topic_sources(:music_source)
|
106
|
+
|
107
|
+
topic.update_attributes(:topic_sources_attributes => [{:id => topic_source.id,
|
108
|
+
:keywords => 'classical, jazz'}])
|
109
|
+
|
110
|
+
topic_source.reload
|
111
|
+
assert_equal(topic_source.keywords, 'classical, jazz')
|
112
|
+
end
|
113
|
+
|
114
|
+
def test_nested_attributes_update_with_string_in_primary_key_3
|
115
|
+
topic = topics(:music)
|
116
|
+
topic_source = topic_sources(:music_source)
|
117
|
+
|
118
|
+
topic.update_attributes(:topic_sources_attributes => [{:id => topic_source.id.to_s,
|
119
|
+
:keywords => 'classical, jazz'}])
|
120
|
+
|
121
|
+
topic_source.reload
|
122
|
+
assert_equal(topic_source.keywords, 'classical, jazz')
|
123
|
+
end
|
124
|
+
end
|
data/test/test_polymorphic.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
-
|
3
|
-
class TestPolymorphic < ActiveSupport::TestCase
|
4
|
-
fixtures :users, :employees, :comments, :hacks
|
5
|
-
|
6
|
-
def test_polymorphic_has_many
|
7
|
-
comments = Hack.find(7).comments
|
8
|
-
assert_equal 7, comments[0].person_id
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_polymorphic_has_one
|
12
|
-
first_comment = Hack.find(7).first_comment
|
13
|
-
assert_equal 7, first_comment.person_id
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_has_many_through
|
17
|
-
user = users(:santiago)
|
18
|
-
article_names = user.articles.collect { |a| a.name }.sort
|
19
|
-
assert_equal ['Article One', 'Article Two'], article_names
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_polymorphic_has_many_through
|
23
|
-
user = users(:santiago)
|
24
|
-
assert_equal(['andrew'], user.hacks.collect { |a| a.name }.sort)
|
25
|
-
end
|
26
|
-
end
|
1
|
+
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
+
|
3
|
+
class TestPolymorphic < ActiveSupport::TestCase
|
4
|
+
fixtures :users, :employees, :comments, :hacks
|
5
|
+
|
6
|
+
def test_polymorphic_has_many
|
7
|
+
comments = Hack.find(7).comments
|
8
|
+
assert_equal 7, comments[0].person_id
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_polymorphic_has_one
|
12
|
+
first_comment = Hack.find(7).first_comment
|
13
|
+
assert_equal 7, first_comment.person_id
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_has_many_through
|
17
|
+
user = users(:santiago)
|
18
|
+
article_names = user.articles.collect { |a| a.name }.sort
|
19
|
+
assert_equal ['Article One', 'Article Two'], article_names
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_polymorphic_has_many_through
|
23
|
+
user = users(:santiago)
|
24
|
+
assert_equal(['andrew'], user.hacks.collect { |a| a.name }.sort)
|
25
|
+
end
|
26
|
+
end
|
data/test/test_predicates.rb
CHANGED
@@ -1,41 +1,41 @@
|
|
1
|
-
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
-
|
3
|
-
class TestEqual < ActiveSupport::TestCase
|
4
|
-
fixtures :departments
|
5
|
-
|
6
|
-
include CompositePrimaryKeys::Predicates
|
7
|
-
|
8
|
-
def test_or
|
9
|
-
dep = Arel::Table.new(:departments)
|
10
|
-
|
11
|
-
predicates = Array.new
|
12
|
-
|
13
|
-
3.times do |i|
|
14
|
-
predicates << dep[:id].eq(i)
|
15
|
-
end
|
16
|
-
|
17
|
-
connection = ActiveRecord::Base.connection
|
18
|
-
quoted = "#{connection.quote_table_name('departments')}.#{connection.quote_column_name('id')}"
|
19
|
-
expected = "((#{quoted} = 0) OR (#{quoted} = 1) OR (#{quoted} = 2))"
|
20
|
-
|
21
|
-
pred = cpk_or_predicate(predicates)
|
22
|
-
assert_equal(with_quoted_identifiers(expected), pred.to_sql)
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_and
|
26
|
-
dep = Arel::Table.new(:departments)
|
27
|
-
|
28
|
-
predicates = Array.new
|
29
|
-
|
30
|
-
3.times do |i|
|
31
|
-
predicates << dep[:id].eq(i)
|
32
|
-
end
|
33
|
-
|
34
|
-
connection = ActiveRecord::Base.connection
|
35
|
-
quoted = "#{connection.quote_table_name('departments')}.#{connection.quote_column_name('id')}"
|
36
|
-
expected = "#{quoted} = 0 AND #{quoted} = 1 AND #{quoted} = 2"
|
37
|
-
|
38
|
-
pred = cpk_and_predicate(predicates)
|
39
|
-
assert_equal(with_quoted_identifiers(expected), pred.to_sql)
|
40
|
-
end
|
1
|
+
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
+
|
3
|
+
class TestEqual < ActiveSupport::TestCase
|
4
|
+
fixtures :departments
|
5
|
+
|
6
|
+
include CompositePrimaryKeys::Predicates
|
7
|
+
|
8
|
+
def test_or
|
9
|
+
dep = Arel::Table.new(:departments)
|
10
|
+
|
11
|
+
predicates = Array.new
|
12
|
+
|
13
|
+
3.times do |i|
|
14
|
+
predicates << dep[:id].eq(i)
|
15
|
+
end
|
16
|
+
|
17
|
+
connection = ActiveRecord::Base.connection
|
18
|
+
quoted = "#{connection.quote_table_name('departments')}.#{connection.quote_column_name('id')}"
|
19
|
+
expected = "((#{quoted} = 0) OR (#{quoted} = 1) OR (#{quoted} = 2))"
|
20
|
+
|
21
|
+
pred = cpk_or_predicate(predicates)
|
22
|
+
assert_equal(with_quoted_identifiers(expected), pred.to_sql)
|
23
|
+
end
|
24
|
+
|
25
|
+
def test_and
|
26
|
+
dep = Arel::Table.new(:departments)
|
27
|
+
|
28
|
+
predicates = Array.new
|
29
|
+
|
30
|
+
3.times do |i|
|
31
|
+
predicates << dep[:id].eq(i)
|
32
|
+
end
|
33
|
+
|
34
|
+
connection = ActiveRecord::Base.connection
|
35
|
+
quoted = "#{connection.quote_table_name('departments')}.#{connection.quote_column_name('id')}"
|
36
|
+
expected = "#{quoted} = 0 AND #{quoted} = 1 AND #{quoted} = 2"
|
37
|
+
|
38
|
+
pred = cpk_and_predicate(predicates)
|
39
|
+
assert_equal(with_quoted_identifiers(expected), pred.to_sql)
|
40
|
+
end
|
41
41
|
end
|
data/test/test_santiago.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
# Test cases devised by Santiago that broke the Composite Primary Keys
|
2
|
-
# code at one point in time. But no more!!!
|
3
|
-
require File.expand_path('../abstract_unit', __FILE__)
|
4
|
-
|
5
|
-
class TestSantiago < ActiveSupport::TestCase
|
6
|
-
fixtures :suburbs, :streets, :users, :articles, :readings
|
7
|
-
|
8
|
-
def test_normal_and_composite_associations
|
9
|
-
assert_not_nil @suburb = Suburb.find([1, 1])
|
10
|
-
assert_equal 1, @suburb.streets.length
|
11
|
-
|
12
|
-
assert_not_nil @street = Street.find(1)
|
13
|
-
assert_not_nil @street.suburb
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_single_keys
|
17
|
-
@santiago = User.find(1)
|
18
|
-
assert_not_nil @santiago.articles
|
19
|
-
assert_equal 2, @santiago.articles.length
|
20
|
-
assert_not_nil @santiago.readings
|
21
|
-
assert_equal 2, @santiago.readings.length
|
22
|
-
end
|
23
|
-
end
|
1
|
+
# Test cases devised by Santiago that broke the Composite Primary Keys
|
2
|
+
# code at one point in time. But no more!!!
|
3
|
+
require File.expand_path('../abstract_unit', __FILE__)
|
4
|
+
|
5
|
+
class TestSantiago < ActiveSupport::TestCase
|
6
|
+
fixtures :suburbs, :streets, :users, :articles, :readings
|
7
|
+
|
8
|
+
def test_normal_and_composite_associations
|
9
|
+
assert_not_nil @suburb = Suburb.find([1, 1])
|
10
|
+
assert_equal 1, @suburb.streets.length
|
11
|
+
|
12
|
+
assert_not_nil @street = Street.find(1)
|
13
|
+
assert_not_nil @street.suburb
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_single_keys
|
17
|
+
@santiago = User.find(1)
|
18
|
+
assert_not_nil @santiago.articles
|
19
|
+
assert_equal 2, @santiago.articles.length
|
20
|
+
assert_not_nil @santiago.readings
|
21
|
+
assert_equal 2, @santiago.readings.length
|
22
|
+
end
|
23
|
+
end
|
data/test/test_suite.rb
CHANGED
@@ -1,34 +1,33 @@
|
|
1
|
-
%w(
|
2
|
-
test_aliases
|
3
|
-
test_associations
|
4
|
-
test_attribute_methods
|
5
|
-
test_attributes
|
6
|
-
test_calculations
|
7
|
-
test_callbacks
|
8
|
-
test_composite_arrays
|
9
|
-
test_create
|
10
|
-
test_delete
|
11
|
-
test_delete_all
|
12
|
-
test_dumpable
|
13
|
-
test_dup
|
14
|
-
test_enum
|
15
|
-
test_equal
|
16
|
-
test_exists
|
17
|
-
test_find
|
18
|
-
test_habtm
|
19
|
-
test_ids
|
20
|
-
test_miscellaneous
|
21
|
-
test_nested_attributes
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
end
|
1
|
+
%w(
|
2
|
+
test_aliases
|
3
|
+
test_associations
|
4
|
+
test_attribute_methods
|
5
|
+
test_attributes
|
6
|
+
test_calculations
|
7
|
+
test_callbacks
|
8
|
+
test_composite_arrays
|
9
|
+
test_create
|
10
|
+
test_delete
|
11
|
+
test_delete_all
|
12
|
+
test_dumpable
|
13
|
+
test_dup
|
14
|
+
test_enum
|
15
|
+
test_equal
|
16
|
+
test_exists
|
17
|
+
test_find
|
18
|
+
test_habtm
|
19
|
+
test_ids
|
20
|
+
test_miscellaneous
|
21
|
+
test_nested_attributes
|
22
|
+
test_pagination
|
23
|
+
test_polymorphic
|
24
|
+
test_predicates
|
25
|
+
test_santiago
|
26
|
+
test_serialize
|
27
|
+
test_touch
|
28
|
+
test_tutorial_example
|
29
|
+
test_update
|
30
|
+
test_validations
|
31
|
+
).each do |test|
|
32
|
+
require File.expand_path("../#{test}", __FILE__)
|
33
|
+
end
|