composite_primary_keys 12.0.2 → 12.0.7
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.
Potentially problematic release.
This version of composite_primary_keys might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/History.rdoc +30 -0
- data/README.rdoc +3 -2
- data/lib/composite_primary_keys.rb +57 -56
- data/lib/composite_primary_keys/active_model/attribute_assignment.rb +19 -0
- data/lib/composite_primary_keys/arel/sqlserver.rb +1 -3
- data/lib/composite_primary_keys/associations/through_association.rb +2 -1
- data/lib/composite_primary_keys/attribute_methods.rb +1 -1
- data/lib/composite_primary_keys/attribute_methods/primary_key.rb +13 -0
- data/lib/composite_primary_keys/base.rb +11 -0
- data/lib/composite_primary_keys/composite_arrays.rb +0 -8
- data/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb +24 -4
- data/lib/composite_primary_keys/connection_adapters/mysql/database_statements.rb +24 -0
- data/lib/composite_primary_keys/connection_adapters/sqlserver/database_statements.rb +32 -11
- data/lib/composite_primary_keys/core.rb +1 -1
- data/lib/composite_primary_keys/persistence.rb +2 -2
- data/lib/composite_primary_keys/relation.rb +100 -25
- data/lib/composite_primary_keys/relation/batches.rb +1 -1
- data/lib/composite_primary_keys/relation/finder_methods.rb +1 -1
- data/lib/composite_primary_keys/relation/predicate_builder/association_query_value.rb +1 -1
- data/lib/composite_primary_keys/version.rb +1 -1
- data/test/abstract_unit.rb +2 -1
- data/test/connections/databases.ci.yml +5 -2
- data/test/fixtures/article.rb +4 -0
- data/test/fixtures/articles.yml +4 -3
- data/test/fixtures/comment.rb +1 -3
- data/test/fixtures/comments.yml +10 -9
- data/test/fixtures/db_definitions/db2-create-tables.sql +0 -14
- data/test/fixtures/db_definitions/db2-drop-tables.sql +1 -3
- data/test/fixtures/db_definitions/mysql.sql +7 -44
- data/test/fixtures/db_definitions/oracle.drop.sql +3 -9
- data/test/fixtures/db_definitions/oracle.sql +12 -48
- data/test/fixtures/db_definitions/postgresql.sql +7 -44
- data/test/fixtures/db_definitions/sqlite.sql +6 -42
- data/test/fixtures/db_definitions/sqlserver.sql +5 -41
- data/test/fixtures/department.rb +8 -3
- data/test/fixtures/departments.yml +4 -4
- data/test/fixtures/readings.yml +2 -2
- data/test/fixtures/restaurants_suburbs.yml +1 -1
- data/test/fixtures/streets.yml +2 -2
- data/test/fixtures/suburbs.yml +2 -2
- data/test/fixtures/user.rb +3 -2
- data/test/test_associations.rb +30 -23
- data/test/test_create.rb +41 -18
- data/test/test_delete.rb +3 -3
- data/test/test_exists.rb +5 -5
- data/test/test_find.rb +21 -2
- data/test/test_habtm.rb +2 -2
- data/test/test_ids.rb +2 -6
- data/test/test_nested_attributes.rb +0 -57
- data/test/test_polymorphic.rb +29 -13
- data/test/test_preload.rb +4 -3
- data/test/test_serialize.rb +2 -2
- data/test/test_update.rb +19 -1
- metadata +11 -25
- data/test/fixtures/hack.rb +0 -5
- data/test/fixtures/hacks.yml +0 -3
- data/test/fixtures/pk_called_id.rb +0 -5
- data/test/fixtures/pk_called_ids.yml +0 -11
- data/test/fixtures/reference_code_using_composite_key_alias.rb +0 -8
- data/test/fixtures/reference_code_using_simple_key_alias.rb +0 -8
- data/test/fixtures/seat.rb +0 -5
- data/test/fixtures/seats.yml +0 -9
- data/test/fixtures/topic.rb +0 -6
- data/test/fixtures/topic_source.rb +0 -7
- data/test/test_aliases.rb +0 -18
- data/test/test_enum.rb +0 -21
- data/test/test_suite.rb +0 -35
data/test/fixtures/hack.rb
DELETED
data/test/fixtures/hacks.yml
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
class ReferenceCodeUsingCompositeKeyAlias < ActiveRecord::Base
|
2
|
-
self.table_name = 'reference_codes'
|
3
|
-
self.primary_key = [:reference_type_id, :reference_code]
|
4
|
-
|
5
|
-
belongs_to :reference_type, :foreign_key => "reference_type_id"
|
6
|
-
|
7
|
-
validates_presence_of :reference_code, :code_label, :abbreviation
|
8
|
-
end
|
@@ -1,8 +0,0 @@
|
|
1
|
-
class ReferenceCodeUsingSimpleKeyAlias < ActiveRecord::Base
|
2
|
-
self.table_name = 'reference_codes'
|
3
|
-
self.primary_key = :code_label
|
4
|
-
|
5
|
-
belongs_to :reference_type, :foreign_key => "reference_type_id"
|
6
|
-
|
7
|
-
validates_presence_of :reference_code, :code_label, :abbreviation
|
8
|
-
end
|
data/test/fixtures/seat.rb
DELETED
data/test/fixtures/seats.yml
DELETED
data/test/fixtures/topic.rb
DELETED
data/test/test_aliases.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
-
|
3
|
-
class TestAliases < ActiveSupport::TestCase
|
4
|
-
fixtures :reference_codes
|
5
|
-
|
6
|
-
def test_primary_key_setter_alias_composite_key
|
7
|
-
reference_code = ReferenceCodeUsingCompositeKeyAlias.find([1, 2])
|
8
|
-
assert_equal 'MRS', reference_code.code_label
|
9
|
-
assert_equal 'Mrs', reference_code.abbreviation
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_primary_key_setter_alias_simple_key
|
13
|
-
reference_code = ReferenceCodeUsingSimpleKeyAlias.find('MRS')
|
14
|
-
assert_equal 1, reference_code.reference_type_id
|
15
|
-
assert_equal 2, reference_code.reference_code
|
16
|
-
assert_equal 'Mrs', reference_code.abbreviation
|
17
|
-
end
|
18
|
-
end
|
data/test/test_enum.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
require File.expand_path('../abstract_unit', __FILE__)
|
2
|
-
|
3
|
-
class TestEnum < ActiveSupport::TestCase
|
4
|
-
fixtures :comments
|
5
|
-
|
6
|
-
def test_enum_was
|
7
|
-
comment = Comment.first
|
8
|
-
assert_nil comment.shown
|
9
|
-
assert_equal({}, comment.changed_attributes)
|
10
|
-
comment.shown = :true
|
11
|
-
assert_equal({ "shown" => nil }, comment.changed_attributes)
|
12
|
-
assert_equal 'true', comment.shown
|
13
|
-
assert_nil comment.shown_was
|
14
|
-
|
15
|
-
comment.save
|
16
|
-
|
17
|
-
comment.shown = :false
|
18
|
-
assert_equal 'false', comment.shown
|
19
|
-
assert_equal 'true', comment.shown_was
|
20
|
-
end
|
21
|
-
end
|
data/test/test_suite.rb
DELETED
@@ -1,35 +0,0 @@
|
|
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_counter_cache
|
10
|
-
test_create
|
11
|
-
test_delete
|
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_optimistic
|
23
|
-
test_pagination
|
24
|
-
test_polymorphic
|
25
|
-
test_predicates
|
26
|
-
test_preload
|
27
|
-
test_santiago
|
28
|
-
test_serialize
|
29
|
-
test_touch
|
30
|
-
test_tutorial_example
|
31
|
-
test_update
|
32
|
-
test_validations
|
33
|
-
).each do |test|
|
34
|
-
require File.expand_path("../#{test}", __FILE__)
|
35
|
-
end
|