composite_primary_keys 7.0.15 → 7.0.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +4 -0
  3. data/lib/composite_primary_keys.rb +5 -0
  4. data/lib/composite_primary_keys/arel/visitors/to_sql.rb +20 -0
  5. data/lib/composite_primary_keys/associations/join_dependency/join_association.rb +22 -22
  6. data/lib/composite_primary_keys/associations/preloader/belongs_to.rb +19 -19
  7. data/lib/composite_primary_keys/composite_predicates.rb +50 -50
  8. data/lib/composite_primary_keys/composite_relation.rb +48 -48
  9. data/lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb +60 -46
  10. data/lib/composite_primary_keys/fixtures.rb +22 -22
  11. data/lib/composite_primary_keys/locking/optimistic.rb +55 -55
  12. data/lib/composite_primary_keys/relation/query_methods.rb +40 -40
  13. data/lib/composite_primary_keys/version.rb +1 -1
  14. data/tasks/databases/oracle.rake +25 -25
  15. data/test/connections/databases.ci.yml +15 -15
  16. data/test/connections/native_oracle/connection.rb +11 -11
  17. data/test/connections/native_oracle_enhanced/connection.rb +16 -16
  18. data/test/fixtures/comment.rb +7 -7
  19. data/test/fixtures/db_definitions/db2-create-tables.sql +126 -126
  20. data/test/fixtures/db_definitions/db2-drop-tables.sql +18 -18
  21. data/test/fixtures/db_definitions/oracle.drop.sql +45 -45
  22. data/test/fixtures/db_definitions/oracle.sql +223 -223
  23. data/test/fixtures/dorm.rb +2 -2
  24. data/test/fixtures/membership.rb +6 -6
  25. data/test/fixtures/membership_statuses.yml +16 -16
  26. data/test/fixtures/memberships.yml +10 -10
  27. data/test/fixtures/product_tariffs.yml +14 -14
  28. data/test/fixtures/reference_code.rb +7 -7
  29. data/test/fixtures/restaurants_suburb.rb +2 -2
  30. data/test/fixtures/suburb.rb +5 -5
  31. data/test/fixtures/topic.rb +5 -5
  32. data/test/fixtures/topic_source.rb +6 -6
  33. data/test/fixtures/topic_sources.yml +3 -3
  34. data/test/fixtures/topics.yml +8 -8
  35. data/test/fixtures/users.yml +10 -10
  36. data/test/test_attribute_methods.rb +63 -63
  37. data/test/test_calculations.rb +42 -42
  38. data/test/test_callbacks.rb +99 -99
  39. data/test/test_delete_all.rb +5 -0
  40. data/test/test_dumpable.rb +15 -15
  41. data/test/test_nested_attributes.rb +124 -124
  42. data/test/test_optimistic.rb +18 -18
  43. data/test/test_predicates.rb +40 -40
  44. data/test/test_santiago.rb +23 -23
  45. data/test/test_suite.rb +34 -34
  46. data/test/test_touch.rb +23 -23
  47. data/test/test_update.rb +71 -71
  48. metadata +4 -3
@@ -1,34 +1,34 @@
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_optimistic
23
- test_pagination
24
- test_polymorphic
25
- test_predicates
26
- test_santiago
27
- test_serialize
28
- test_touch
29
- test_tutorial_example
30
- test_update
31
- test_validations
32
- ).each do |test|
33
- require File.expand_path("../#{test}", __FILE__)
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_optimistic
23
+ test_pagination
24
+ test_polymorphic
25
+ test_predicates
26
+ test_santiago
27
+ test_serialize
28
+ test_touch
29
+ test_tutorial_example
30
+ test_update
31
+ test_validations
32
+ ).each do |test|
33
+ require File.expand_path("../#{test}", __FILE__)
34
+ end
@@ -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 TestTouch < ActiveSupport::TestCase
6
- fixtures :products, :tariffs
7
-
8
- def test_touching_a_record_updates_its_timestamp
9
- tariff = tariffs(:flat)
10
- previous_amount = tariff.amount
11
- previously_updated_at = tariff.updated_at
12
-
13
- tariff.amount = previous_amount + 1
14
- sleep 1.0 # we need to sleep for 1 second because the times updated (on mysql, at least) are only precise to 1 second.
15
- tariff.touch
16
- assert_not_equal previously_updated_at, tariff.updated_at
17
- assert_equal previous_amount + 1, tariff.amount
18
- assert tariff.amount_changed?, 'tarif amount should have changed'
19
- assert tariff.changed?, 'tarif should be marked as changed'
20
- tariff.reload
21
- assert_not_equal previously_updated_at, tariff.updated_at
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 TestTouch < ActiveSupport::TestCase
6
+ fixtures :products, :tariffs
7
+
8
+ def test_touching_a_record_updates_its_timestamp
9
+ tariff = tariffs(:flat)
10
+ previous_amount = tariff.amount
11
+ previously_updated_at = tariff.updated_at
12
+
13
+ tariff.amount = previous_amount + 1
14
+ sleep 1.0 # we need to sleep for 1 second because the times updated (on mysql, at least) are only precise to 1 second.
15
+ tariff.touch
16
+ assert_not_equal previously_updated_at, tariff.updated_at
17
+ assert_equal previous_amount + 1, tariff.amount
18
+ assert tariff.amount_changed?, 'tarif amount should have changed'
19
+ assert tariff.changed?, 'tarif should be marked as changed'
20
+ tariff.reload
21
+ assert_not_equal previously_updated_at, tariff.updated_at
22
+ end
23
+ end
@@ -1,71 +1,71 @@
1
- require File.expand_path('../abstract_unit', __FILE__)
2
-
3
- class TestUpdate < ActiveSupport::TestCase
4
- fixtures :reference_types, :reference_codes
5
-
6
- CLASSES = {
7
- :single => {
8
- :class => ReferenceType,
9
- :primary_keys => :reference_type_id,
10
- :update => { :description => 'RT Desc' },
11
- },
12
- :dual => {
13
- :class => ReferenceCode,
14
- :primary_keys => [:reference_type_id, :reference_code],
15
- :update => { :description => 'RT Desc' },
16
- },
17
- }
18
-
19
- def setup
20
- self.class.classes = CLASSES
21
- end
22
-
23
- def test_setup
24
- testing_with do
25
- assert_not_nil @klass_info[:update]
26
- end
27
- end
28
-
29
- def test_update_attributes
30
- testing_with do
31
- assert(@first.update_attributes(@klass_info[:update]))
32
- assert(@first.reload)
33
- @klass_info[:update].each_pair do |attr_name, new_value|
34
- assert_equal(new_value, @first[attr_name])
35
- end
36
- end
37
- end
38
-
39
- def test_update_primary_key
40
- obj = ReferenceCode.find([1,1])
41
- obj.reference_type_id = 2
42
- obj.reference_code = 3
43
- assert(obj.primary_key_changed?)
44
- assert_equal({"reference_type_id" => 1, "reference_code" => 1}, obj.primary_key_was)
45
- assert_equal({"reference_type_id" => 2, "reference_code" => 3}, obj.ids_hash)
46
- assert(obj.save)
47
- assert(obj.reload)
48
- assert_equal(2, obj.reference_type_id)
49
- assert_equal(3, obj.reference_code)
50
- assert_equal({"reference_type_id" => 2, "reference_code" => 3}, obj.ids_hash)
51
- assert_equal([2, 3], obj.id)
52
- end
53
-
54
- def test_update_attribute
55
- obj = ReferenceType.find(1)
56
- obj[:abbreviation] = 'a'
57
- obj['abbreviation'] = 'b'
58
- assert(obj.save)
59
- assert(obj.reload)
60
- assert_equal('b', obj.abbreviation)
61
- end
62
-
63
- def test_update_all
64
- assert_nothing_raised do
65
- reference_code = ReferenceCode.create
66
- primary_key = reference_code.class.primary_key
67
- ReferenceCode.where(primary_key => reference_code[primary_key]).
68
- update_all(description: 'random value')
69
- end
70
- end
71
- end
1
+ require File.expand_path('../abstract_unit', __FILE__)
2
+
3
+ class TestUpdate < ActiveSupport::TestCase
4
+ fixtures :reference_types, :reference_codes
5
+
6
+ CLASSES = {
7
+ :single => {
8
+ :class => ReferenceType,
9
+ :primary_keys => :reference_type_id,
10
+ :update => { :description => 'RT Desc' },
11
+ },
12
+ :dual => {
13
+ :class => ReferenceCode,
14
+ :primary_keys => [:reference_type_id, :reference_code],
15
+ :update => { :description => 'RT Desc' },
16
+ },
17
+ }
18
+
19
+ def setup
20
+ self.class.classes = CLASSES
21
+ end
22
+
23
+ def test_setup
24
+ testing_with do
25
+ assert_not_nil @klass_info[:update]
26
+ end
27
+ end
28
+
29
+ def test_update_attributes
30
+ testing_with do
31
+ assert(@first.update_attributes(@klass_info[:update]))
32
+ assert(@first.reload)
33
+ @klass_info[:update].each_pair do |attr_name, new_value|
34
+ assert_equal(new_value, @first[attr_name])
35
+ end
36
+ end
37
+ end
38
+
39
+ def test_update_primary_key
40
+ obj = ReferenceCode.find([1,1])
41
+ obj.reference_type_id = 2
42
+ obj.reference_code = 3
43
+ assert(obj.primary_key_changed?)
44
+ assert_equal({"reference_type_id" => 1, "reference_code" => 1}, obj.primary_key_was)
45
+ assert_equal({"reference_type_id" => 2, "reference_code" => 3}, obj.ids_hash)
46
+ assert(obj.save)
47
+ assert(obj.reload)
48
+ assert_equal(2, obj.reference_type_id)
49
+ assert_equal(3, obj.reference_code)
50
+ assert_equal({"reference_type_id" => 2, "reference_code" => 3}, obj.ids_hash)
51
+ assert_equal([2, 3], obj.id)
52
+ end
53
+
54
+ def test_update_attribute
55
+ obj = ReferenceType.find(1)
56
+ obj[:abbreviation] = 'a'
57
+ obj['abbreviation'] = 'b'
58
+ assert(obj.save)
59
+ assert(obj.reload)
60
+ assert_equal('b', obj.abbreviation)
61
+ end
62
+
63
+ def test_update_all
64
+ assert_nothing_raised do
65
+ reference_code = ReferenceCode.create
66
+ primary_key = reference_code.class.primary_key
67
+ ReferenceCode.where(primary_key => reference_code[primary_key]).
68
+ update_all(description: 'random value')
69
+ end
70
+ end
71
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: composite_primary_keys
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.0.15
4
+ version: 7.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Charlie Savage
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-02 00:00:00.000000000 Z
11
+ date: 2015-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -35,6 +35,7 @@ files:
35
35
  - README_DB2.rdoc
36
36
  - Rakefile
37
37
  - lib/composite_primary_keys.rb
38
+ - lib/composite_primary_keys/arel/visitors/to_sql.rb
38
39
  - lib/composite_primary_keys/associations/association.rb
39
40
  - lib/composite_primary_keys/associations/association_scope.rb
40
41
  - lib/composite_primary_keys/associations/has_and_belongs_to_many_association.rb
@@ -221,7 +222,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
221
222
  version: '0'
222
223
  requirements: []
223
224
  rubyforge_project:
224
- rubygems_version: 2.4.5
225
+ rubygems_version: 2.4.5.1
225
226
  signing_key:
226
227
  specification_version: 4
227
228
  summary: Composite key support for ActiveRecord