composite_primary_keys 12.0.2 → 12.0.7

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of composite_primary_keys might be problematic. Click here for more details.

Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +30 -0
  3. data/README.rdoc +3 -2
  4. data/lib/composite_primary_keys.rb +57 -56
  5. data/lib/composite_primary_keys/active_model/attribute_assignment.rb +19 -0
  6. data/lib/composite_primary_keys/arel/sqlserver.rb +1 -3
  7. data/lib/composite_primary_keys/associations/through_association.rb +2 -1
  8. data/lib/composite_primary_keys/attribute_methods.rb +1 -1
  9. data/lib/composite_primary_keys/attribute_methods/primary_key.rb +13 -0
  10. data/lib/composite_primary_keys/base.rb +11 -0
  11. data/lib/composite_primary_keys/composite_arrays.rb +0 -8
  12. data/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb +24 -4
  13. data/lib/composite_primary_keys/connection_adapters/mysql/database_statements.rb +24 -0
  14. data/lib/composite_primary_keys/connection_adapters/sqlserver/database_statements.rb +32 -11
  15. data/lib/composite_primary_keys/core.rb +1 -1
  16. data/lib/composite_primary_keys/persistence.rb +2 -2
  17. data/lib/composite_primary_keys/relation.rb +100 -25
  18. data/lib/composite_primary_keys/relation/batches.rb +1 -1
  19. data/lib/composite_primary_keys/relation/finder_methods.rb +1 -1
  20. data/lib/composite_primary_keys/relation/predicate_builder/association_query_value.rb +1 -1
  21. data/lib/composite_primary_keys/version.rb +1 -1
  22. data/test/abstract_unit.rb +2 -1
  23. data/test/connections/databases.ci.yml +5 -2
  24. data/test/fixtures/article.rb +4 -0
  25. data/test/fixtures/articles.yml +4 -3
  26. data/test/fixtures/comment.rb +1 -3
  27. data/test/fixtures/comments.yml +10 -9
  28. data/test/fixtures/db_definitions/db2-create-tables.sql +0 -14
  29. data/test/fixtures/db_definitions/db2-drop-tables.sql +1 -3
  30. data/test/fixtures/db_definitions/mysql.sql +7 -44
  31. data/test/fixtures/db_definitions/oracle.drop.sql +3 -9
  32. data/test/fixtures/db_definitions/oracle.sql +12 -48
  33. data/test/fixtures/db_definitions/postgresql.sql +7 -44
  34. data/test/fixtures/db_definitions/sqlite.sql +6 -42
  35. data/test/fixtures/db_definitions/sqlserver.sql +5 -41
  36. data/test/fixtures/department.rb +8 -3
  37. data/test/fixtures/departments.yml +4 -4
  38. data/test/fixtures/readings.yml +2 -2
  39. data/test/fixtures/restaurants_suburbs.yml +1 -1
  40. data/test/fixtures/streets.yml +2 -2
  41. data/test/fixtures/suburbs.yml +2 -2
  42. data/test/fixtures/user.rb +3 -2
  43. data/test/test_associations.rb +30 -23
  44. data/test/test_create.rb +41 -18
  45. data/test/test_delete.rb +3 -3
  46. data/test/test_exists.rb +5 -5
  47. data/test/test_find.rb +21 -2
  48. data/test/test_habtm.rb +2 -2
  49. data/test/test_ids.rb +2 -6
  50. data/test/test_nested_attributes.rb +0 -57
  51. data/test/test_polymorphic.rb +29 -13
  52. data/test/test_preload.rb +4 -3
  53. data/test/test_serialize.rb +2 -2
  54. data/test/test_update.rb +19 -1
  55. metadata +11 -25
  56. data/test/fixtures/hack.rb +0 -5
  57. data/test/fixtures/hacks.yml +0 -3
  58. data/test/fixtures/pk_called_id.rb +0 -5
  59. data/test/fixtures/pk_called_ids.yml +0 -11
  60. data/test/fixtures/reference_code_using_composite_key_alias.rb +0 -8
  61. data/test/fixtures/reference_code_using_simple_key_alias.rb +0 -8
  62. data/test/fixtures/seat.rb +0 -5
  63. data/test/fixtures/seats.yml +0 -9
  64. data/test/fixtures/topic.rb +0 -6
  65. data/test/fixtures/topic_source.rb +0 -7
  66. data/test/test_aliases.rb +0 -18
  67. data/test/test_enum.rb +0 -21
  68. data/test/test_suite.rb +0 -35
@@ -1,5 +0,0 @@
1
- class Hack < ActiveRecord::Base
2
- has_many :comments, :as => :person
3
-
4
- has_one :first_comment, :as => :person, :class_name => "Comment"
5
- end
@@ -1,3 +0,0 @@
1
- andrew:
2
- id: 7
3
- name: andrew
@@ -1,5 +0,0 @@
1
- class PkCalledId < ActiveRecord::Base
2
- self.primary_keys = :id, :reference_code
3
-
4
- validates_presence_of :reference_code, :code_label, :abbreviation
5
- end
@@ -1,11 +0,0 @@
1
- name_prefix_mr:
2
- id: 1
3
- reference_code: 1
4
- code_label: MR
5
- abbreviation: Mr
6
-
7
- name_prefix_mrs:
8
- id: 2
9
- reference_code: 1
10
- code_label: MRS
11
- abbreviation: Mrs
@@ -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
@@ -1,5 +0,0 @@
1
- class Seat < ActiveRecord::Base
2
- self.primary_keys = [:flight_number, :seat]
3
-
4
- validates_uniqueness_of :customer
5
- end
@@ -1,9 +0,0 @@
1
- seat1:
2
- flight_number: 1
3
- seat: 1
4
- customer: 1
5
-
6
- seat2:
7
- flight_number: 1
8
- seat: 2
9
- customer: 2
@@ -1,6 +0,0 @@
1
- class Topic < ActiveRecord::Base
2
- has_many :topic_sources, dependent: :destroy
3
- accepts_nested_attributes_for :topic_sources
4
-
5
- validates :name, :feed_size, presence: true
6
- end
@@ -1,7 +0,0 @@
1
- class TopicSource < ActiveRecord::Base
2
- self.primary_keys = :topic_id, :platform
3
-
4
- belongs_to :topic, inverse_of: :topic_sources
5
-
6
- validates :platform, presence: true
7
- end
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