composite_primary_keys 10.0.3 → 10.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +6 -0
  3. data/lib/composite_primary_keys.rb +0 -2
  4. data/lib/composite_primary_keys/associations/preloader/association.rb +2 -0
  5. data/lib/composite_primary_keys/attribute_methods/primary_key.rb +1 -1
  6. data/lib/composite_primary_keys/connection_adapters/abstract_adapter.rb +10 -10
  7. data/lib/composite_primary_keys/locking/optimistic.rb +21 -31
  8. data/lib/composite_primary_keys/relation.rb +14 -3
  9. data/lib/composite_primary_keys/version.rb +1 -1
  10. data/scripts/console.rb +48 -48
  11. data/scripts/txt2html +76 -76
  12. data/scripts/txt2js +65 -65
  13. data/tasks/website.rake +18 -18
  14. data/test/README_tests.rdoc +56 -56
  15. data/test/connections/databases.yml +40 -30
  16. data/test/db_test.rb +52 -52
  17. data/test/fixtures/articles.yml +6 -6
  18. data/test/fixtures/capitol.rb +3 -3
  19. data/test/fixtures/capitols.yml +16 -16
  20. data/test/fixtures/comments.yml +15 -15
  21. data/test/fixtures/department.rb +5 -5
  22. data/test/fixtures/departments.yml +15 -15
  23. data/test/fixtures/dorms.yml +4 -4
  24. data/test/fixtures/group.rb +2 -2
  25. data/test/fixtures/groups.yml +6 -6
  26. data/test/fixtures/hack.rb +4 -4
  27. data/test/fixtures/hacks.yml +2 -2
  28. data/test/fixtures/membership_status.rb +2 -2
  29. data/test/fixtures/product.rb +9 -9
  30. data/test/fixtures/product_tariff.rb +5 -5
  31. data/test/fixtures/products.yml +11 -11
  32. data/test/fixtures/reading.rb +4 -4
  33. data/test/fixtures/readings.yml +10 -10
  34. data/test/fixtures/reference_code_using_composite_key_alias.rb +8 -8
  35. data/test/fixtures/reference_code_using_simple_key_alias.rb +8 -8
  36. data/test/fixtures/reference_codes.yml +28 -28
  37. data/test/fixtures/reference_types.yml +9 -9
  38. data/test/fixtures/restaurant.rb +9 -9
  39. data/test/fixtures/restaurants.yml +14 -14
  40. data/test/fixtures/restaurants_suburbs.yml +10 -10
  41. data/test/fixtures/room.rb +11 -11
  42. data/test/fixtures/room_assignment.rb +13 -13
  43. data/test/fixtures/room_assignments.yml +24 -24
  44. data/test/fixtures/room_attribute.rb +2 -2
  45. data/test/fixtures/room_attribute_assignment.rb +4 -4
  46. data/test/fixtures/room_attribute_assignments.yml +4 -4
  47. data/test/fixtures/room_attributes.yml +2 -2
  48. data/test/fixtures/rooms.yml +12 -12
  49. data/test/fixtures/seat.rb +5 -5
  50. data/test/fixtures/seats.yml +8 -8
  51. data/test/fixtures/street.rb +2 -2
  52. data/test/fixtures/streets.yml +16 -16
  53. data/test/fixtures/student.rb +3 -3
  54. data/test/fixtures/students.yml +15 -15
  55. data/test/fixtures/suburbs.yml +14 -14
  56. data/test/plugins/pagination.rb +405 -405
  57. data/test/plugins/pagination_helper.rb +135 -135
  58. data/test/setup.rb +50 -50
  59. data/test/test_aliases.rb +18 -18
  60. data/test/test_composite_arrays.rb +24 -24
  61. data/test/test_counter_cache.rb +30 -30
  62. data/test/test_dup.rb +37 -37
  63. data/test/test_exists.rb +39 -39
  64. data/test/test_miscellaneous.rb +32 -32
  65. data/test/test_pagination.rb +35 -35
  66. data/test/test_preload.rb +7 -0
  67. data/test/test_validations.rb +13 -13
  68. metadata +5 -6
  69. data/lib/composite_primary_keys/attribute_set/builder.rb +0 -22
@@ -1,7 +1,7 @@
1
- first:
2
- id: 1
3
- name: Article One
4
-
5
- second:
6
- id: 2
1
+ first:
2
+ id: 1
3
+ name: Article One
4
+
5
+ second:
6
+ id: 2
7
7
  name: Article Two
@@ -1,3 +1,3 @@
1
- class Capitol < ActiveRecord::Base
2
- self.primary_keys = :country, :city
3
- end
1
+ class Capitol < ActiveRecord::Base
2
+ self.primary_keys = :country, :city
3
+ end
@@ -1,16 +1,16 @@
1
- netherlands:
2
- country: The Netherlands
3
- city: Amsterdam
4
-
5
- france:
6
- country: France
7
- city: Paris
8
-
9
- canada:
10
- country: Canada
11
- city: Ottawa
12
-
13
- mexico:
14
- country: Mexico
15
- city: Mexico City
16
-
1
+ netherlands:
2
+ country: The Netherlands
3
+ city: Amsterdam
4
+
5
+ france:
6
+ country: France
7
+ city: Paris
8
+
9
+ canada:
10
+ country: Canada
11
+ city: Ottawa
12
+
13
+ mexico:
14
+ country: Mexico
15
+ city: Mexico City
16
+
@@ -1,16 +1,16 @@
1
- comment1:
2
- id: 1
3
- person_id: 1
4
- person_type: Employee
5
-
6
- comment2:
7
- id: 2
8
- person_id: 1
9
- person_type: User
10
- hack_id: 7
11
-
12
- comment3:
13
- id: 3
14
- person_id: 7
15
- person_type: Hack
1
+ comment1:
2
+ id: 1
3
+ person_id: 1
4
+ person_type: Employee
5
+
6
+ comment2:
7
+ id: 2
8
+ person_id: 1
9
+ person_type: User
10
+ hack_id: 7
11
+
12
+ comment3:
13
+ id: 3
14
+ person_id: 7
15
+ person_type: Hack
16
16
 
@@ -1,5 +1,5 @@
1
- class Department < ActiveRecord::Base
2
- self.primary_keys = :department_id, :location_id
3
- has_many :employees, :foreign_key => [:department_id, :location_id]
4
- has_one :head, :class_name => 'Employee', :foreign_key => [:department_id, :location_id], :dependent => :delete
5
- end
1
+ class Department < ActiveRecord::Base
2
+ self.primary_keys = :department_id, :location_id
3
+ has_many :employees, :foreign_key => [:department_id, :location_id]
4
+ has_one :head, :class_name => 'Employee', :foreign_key => [:department_id, :location_id], :dependent => :delete
5
+ end
@@ -1,15 +1,15 @@
1
- accounting:
2
- department_id: 1
3
- location_id: 1
4
-
5
- engineering:
6
- department_id: 2
7
- location_id: 1
8
-
9
- human_resources:
10
- department_id: 3
11
- location_id: 2
12
-
13
- offsite_accounting:
14
- department_id: 1
15
- location_id: 2
1
+ accounting:
2
+ department_id: 1
3
+ location_id: 1
4
+
5
+ engineering:
6
+ department_id: 2
7
+ location_id: 1
8
+
9
+ human_resources:
10
+ department_id: 3
11
+ location_id: 2
12
+
13
+ offsite_accounting:
14
+ department_id: 1
15
+ location_id: 2
@@ -1,5 +1,5 @@
1
- branner:
2
- id: 1
3
-
4
- toyon:
1
+ branner:
2
+ id: 1
3
+
4
+ toyon:
5
5
  id: 2
@@ -1,3 +1,3 @@
1
- class Group < ActiveRecord::Base
2
- has_many :memberships
1
+ class Group < ActiveRecord::Base
2
+ has_many :memberships
3
3
  end
@@ -1,7 +1,7 @@
1
- cpk:
2
- id: 1
3
- name: Composite Primary Keys
4
-
5
- group2:
6
- id: 2
1
+ cpk:
2
+ id: 1
3
+ name: Composite Primary Keys
4
+
5
+ group2:
6
+ id: 2
7
7
  name: Grupo Dos
@@ -1,5 +1,5 @@
1
- class Hack < ActiveRecord::Base
2
- has_many :comments, :as => :person
3
-
4
- has_one :first_comment, :as => :person, :class_name => "Comment"
1
+ class Hack < ActiveRecord::Base
2
+ has_many :comments, :as => :person
3
+
4
+ has_one :first_comment, :as => :person, :class_name => "Comment"
5
5
  end
@@ -1,3 +1,3 @@
1
- andrew:
2
- id: 7
1
+ andrew:
2
+ id: 7
3
3
  name: andrew
@@ -1,3 +1,3 @@
1
- class MembershipStatus < ActiveRecord::Base
2
- belongs_to :membership, :foreign_key => [:user_id, :group_id]
1
+ class MembershipStatus < ActiveRecord::Base
2
+ belongs_to :membership, :foreign_key => [:user_id, :group_id]
3
3
  end
@@ -1,9 +1,9 @@
1
- class Product < ActiveRecord::Base
2
- self.primary_keys = :id # redundant
3
- has_many :product_tariffs, :foreign_key => :product_id, :dependent => :delete_all
4
- has_many :tariffs, :through => :product_tariffs, :foreign_key => [:tariff_id, :tariff_start_date]
5
-
6
- has_and_belongs_to_many :restaurants,
7
- :foreign_key => :product_id,
8
- :association_foreign_key => [:franchise_id, :store_id]
9
- end
1
+ class Product < ActiveRecord::Base
2
+ self.primary_keys = :id # redundant
3
+ has_many :product_tariffs, :foreign_key => :product_id, :dependent => :delete_all
4
+ has_many :tariffs, :through => :product_tariffs, :foreign_key => [:tariff_id, :tariff_start_date]
5
+
6
+ has_and_belongs_to_many :restaurants,
7
+ :foreign_key => :product_id,
8
+ :association_foreign_key => [:franchise_id, :store_id]
9
+ end
@@ -1,5 +1,5 @@
1
- class ProductTariff < ActiveRecord::Base
2
- self.primary_keys = :product_id, :tariff_id, :tariff_start_date
3
- belongs_to :product, :foreign_key => :product_id
4
- belongs_to :tariff, :foreign_key => [:tariff_id, :tariff_start_date]
5
- end
1
+ class ProductTariff < ActiveRecord::Base
2
+ self.primary_keys = :product_id, :tariff_id, :tariff_start_date
3
+ belongs_to :product, :foreign_key => :product_id
4
+ belongs_to :tariff, :foreign_key => [:tariff_id, :tariff_start_date]
5
+ end
@@ -1,11 +1,11 @@
1
- first_product:
2
- id: 1
3
- name: Product One
4
-
5
- second_product:
6
- id: 2
7
- name: Product Two
8
-
9
- third_product:
10
- id: 3
11
- name: Product Three
1
+ first_product:
2
+ id: 1
3
+ name: Product One
4
+
5
+ second_product:
6
+ id: 2
7
+ name: Product Two
8
+
9
+ third_product:
10
+ id: 3
11
+ name: Product Three
@@ -1,4 +1,4 @@
1
- class Reading < ActiveRecord::Base
2
- belongs_to :article
3
- belongs_to :user
4
- end
1
+ class Reading < ActiveRecord::Base
2
+ belongs_to :article
3
+ belongs_to :user
4
+ end
@@ -1,11 +1,11 @@
1
- santiago_first:
2
- id: 1
3
- user_id: 1
4
- article_id: 1
5
- rating: 4
6
-
7
- santiago_second:
8
- id: 2
9
- user_id: 1
10
- article_id: 2
1
+ santiago_first:
2
+ id: 1
3
+ user_id: 1
4
+ article_id: 1
5
+ rating: 4
6
+
7
+ santiago_second:
8
+ id: 2
9
+ user_id: 1
10
+ article_id: 2
11
11
  rating: 5
@@ -1,8 +1,8 @@
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
+ 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 +1,8 @@
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
+ 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,29 +1,29 @@
1
- name_prefix_mr:
2
- reference_type_id: 1
3
- reference_code: 1
4
- code_label: MR
5
- abbreviation: Mr
6
-
7
- name_prefix_mrs:
8
- reference_type_id: 1
9
- reference_code: 2
10
- code_label: MRS
11
- abbreviation: Mrs
12
-
13
- name_prefix_ms:
14
- reference_type_id: 1
15
- reference_code: 3
16
- code_label: MS
17
- abbreviation: Ms
18
-
19
- gender_male:
20
- reference_type_id: 2
21
- reference_code: 1
22
- code_label: MALE
23
- abbreviation: Male
24
-
25
- gender_female:
26
- reference_type_id: 2
27
- reference_code: 2
28
- code_label: FEMALE
1
+ name_prefix_mr:
2
+ reference_type_id: 1
3
+ reference_code: 1
4
+ code_label: MR
5
+ abbreviation: Mr
6
+
7
+ name_prefix_mrs:
8
+ reference_type_id: 1
9
+ reference_code: 2
10
+ code_label: MRS
11
+ abbreviation: Mrs
12
+
13
+ name_prefix_ms:
14
+ reference_type_id: 1
15
+ reference_code: 3
16
+ code_label: MS
17
+ abbreviation: Ms
18
+
19
+ gender_male:
20
+ reference_type_id: 2
21
+ reference_code: 1
22
+ code_label: MALE
23
+ abbreviation: Male
24
+
25
+ gender_female:
26
+ reference_type_id: 2
27
+ reference_code: 2
28
+ code_label: FEMALE
29
29
  abbreviation: Female
@@ -1,9 +1,9 @@
1
- name_prefix:
2
- reference_type_id: 1
3
- type_label: NAME_PREFIX
4
- abbreviation: Name Prefix
5
-
6
- gender:
7
- reference_type_id: 2
8
- type_label: GENDER
9
- abbreviation: Gender
1
+ name_prefix:
2
+ reference_type_id: 1
3
+ type_label: NAME_PREFIX
4
+ abbreviation: Name Prefix
5
+
6
+ gender:
7
+ reference_type_id: 2
8
+ type_label: GENDER
9
+ abbreviation: Gender
@@ -1,9 +1,9 @@
1
- class Restaurant < ActiveRecord::Base
2
- self.primary_keys = :franchise_id, :store_id
3
- has_and_belongs_to_many :suburbs,
4
- :foreign_key => [:franchise_id, :store_id],
5
- :association_foreign_key => [:city_id, :suburb_id]
6
- has_and_belongs_to_many :products,
7
- :foreign_key => [:franchise_id, :store_id],
8
- :association_foreign_key => :product_id
9
- end
1
+ class Restaurant < ActiveRecord::Base
2
+ self.primary_keys = :franchise_id, :store_id
3
+ has_and_belongs_to_many :suburbs,
4
+ :foreign_key => [:franchise_id, :store_id],
5
+ :association_foreign_key => [:city_id, :suburb_id]
6
+ has_and_belongs_to_many :products,
7
+ :foreign_key => [:franchise_id, :store_id],
8
+ :association_foreign_key => :product_id
9
+ end
@@ -1,14 +1,14 @@
1
- mcdonalds:
2
- franchise_id: 1
3
- store_id: 1
4
- name: McDonalds
5
-
6
- subway_one:
7
- franchise_id: 2
8
- store_id: 1
9
- name: Subway 1
10
-
11
- subway_two:
12
- franchise_id: 2
13
- store_id: 2
14
- name: Subway 2
1
+ mcdonalds:
2
+ franchise_id: 1
3
+ store_id: 1
4
+ name: McDonalds
5
+
6
+ subway_one:
7
+ franchise_id: 2
8
+ store_id: 1
9
+ name: Subway 1
10
+
11
+ subway_two:
12
+ franchise_id: 2
13
+ store_id: 2
14
+ name: Subway 2