composite_primary_keys 8.1.6 → 8.1.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +5 -5
  2. data/History.rdoc +5 -0
  3. data/lib/composite_primary_keys/connection_adapters/abstract_adapter.rb +10 -10
  4. data/lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb +1 -1
  5. data/lib/composite_primary_keys/relation/batches.rb +1 -1
  6. data/lib/composite_primary_keys/version.rb +1 -1
  7. data/scripts/console.rb +48 -48
  8. data/scripts/txt2html +76 -76
  9. data/scripts/txt2js +65 -65
  10. data/tasks/website.rake +18 -18
  11. data/test/README_tests.rdoc +56 -56
  12. data/test/connections/databases.yml +39 -30
  13. data/test/db_test.rb +52 -52
  14. data/test/fixtures/articles.yml +6 -6
  15. data/test/fixtures/capitol.rb +3 -3
  16. data/test/fixtures/capitols.yml +16 -16
  17. data/test/fixtures/comments.yml +15 -15
  18. data/test/fixtures/department.rb +5 -5
  19. data/test/fixtures/departments.yml +15 -15
  20. data/test/fixtures/dorms.yml +4 -4
  21. data/test/fixtures/group.rb +2 -2
  22. data/test/fixtures/groups.yml +6 -6
  23. data/test/fixtures/hack.rb +4 -4
  24. data/test/fixtures/hacks.yml +2 -2
  25. data/test/fixtures/membership_status.rb +2 -2
  26. data/test/fixtures/product.rb +9 -9
  27. data/test/fixtures/product_tariff.rb +5 -5
  28. data/test/fixtures/products.yml +11 -11
  29. data/test/fixtures/reading.rb +4 -4
  30. data/test/fixtures/readings.yml +10 -10
  31. data/test/fixtures/reference_code_using_composite_key_alias.rb +8 -8
  32. data/test/fixtures/reference_code_using_simple_key_alias.rb +8 -8
  33. data/test/fixtures/reference_codes.yml +28 -28
  34. data/test/fixtures/reference_types.yml +9 -9
  35. data/test/fixtures/restaurant.rb +9 -9
  36. data/test/fixtures/restaurants.yml +14 -14
  37. data/test/fixtures/restaurants_suburbs.yml +10 -10
  38. data/test/fixtures/room.rb +11 -11
  39. data/test/fixtures/room_assignment.rb +13 -13
  40. data/test/fixtures/room_assignments.yml +24 -24
  41. data/test/fixtures/room_attribute.rb +2 -2
  42. data/test/fixtures/room_attribute_assignment.rb +4 -4
  43. data/test/fixtures/room_attribute_assignments.yml +4 -4
  44. data/test/fixtures/room_attributes.yml +2 -2
  45. data/test/fixtures/rooms.yml +12 -12
  46. data/test/fixtures/seat.rb +5 -5
  47. data/test/fixtures/seats.yml +8 -8
  48. data/test/fixtures/street.rb +2 -2
  49. data/test/fixtures/streets.yml +16 -16
  50. data/test/fixtures/student.rb +3 -3
  51. data/test/fixtures/students.yml +15 -15
  52. data/test/fixtures/suburbs.yml +14 -14
  53. data/test/fixtures/tariffs.yml +14 -14
  54. data/test/plugins/pagination.rb +405 -405
  55. data/test/plugins/pagination_helper.rb +135 -135
  56. data/test/setup.rb +50 -50
  57. data/test/test_aliases.rb +18 -18
  58. data/test/test_composite_arrays.rb +24 -24
  59. data/test/test_counter_cache.rb +30 -30
  60. data/test/test_dup.rb +37 -37
  61. data/test/test_exists.rb +39 -39
  62. data/test/test_miscellaneous.rb +32 -32
  63. data/test/test_pagination.rb +35 -35
  64. data/test/test_update_all.rb +17 -0
  65. data/test/test_validations.rb +13 -13
  66. metadata +5 -4
@@ -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
@@ -1,11 +1,11 @@
1
- a:
2
- franchise_id: 1
3
- store_id: 1
4
- city_id: 1
5
- suburb_id: 1
6
-
7
- b:
8
- franchise_id: 1
9
- store_id: 1
10
- city_id: 2
1
+ a:
2
+ franchise_id: 1
3
+ store_id: 1
4
+ city_id: 1
5
+ suburb_id: 1
6
+
7
+ b:
8
+ franchise_id: 1
9
+ store_id: 1
10
+ city_id: 2
11
11
  suburb_id: 1
@@ -1,11 +1,11 @@
1
- class Room < ActiveRecord::Base
2
- self.primary_keys = :dorm_id, :room_id
3
- belongs_to :dorm
4
- has_many :room_assignments, :foreign_key => [:dorm_id, :room_id]
5
- has_many :room_attribute_assignments, :foreign_key => [:dorm_id, :room_id]
6
- has_many :room_attributes, :through => :room_attribute_assignments
7
-
8
- def find_custom_room_attributes
9
- room_attributes.where("room_attributes.name != ?", "type")
10
- end
11
- end
1
+ class Room < ActiveRecord::Base
2
+ self.primary_keys = :dorm_id, :room_id
3
+ belongs_to :dorm
4
+ has_many :room_assignments, :foreign_key => [:dorm_id, :room_id]
5
+ has_many :room_attribute_assignments, :foreign_key => [:dorm_id, :room_id]
6
+ has_many :room_attributes, :through => :room_attribute_assignments
7
+
8
+ def find_custom_room_attributes
9
+ room_attributes.where("room_attributes.name != ?", "type")
10
+ end
11
+ end
@@ -1,14 +1,14 @@
1
- class RoomAssignment < ActiveRecord::Base
2
- self.primary_keys = :student_id, :dorm_id, :room_id
3
- belongs_to :student
4
- belongs_to :room, :foreign_key => [:dorm_id, :room_id], :primary_key => [:dorm_id, :room_id]
5
- validates_uniqueness_of :student_id
6
-
7
- before_destroy do |record|
8
- puts record
9
- end
10
-
11
- after_destroy do |record|
12
- puts record
13
- end
1
+ class RoomAssignment < ActiveRecord::Base
2
+ self.primary_keys = :student_id, :dorm_id, :room_id
3
+ belongs_to :student
4
+ belongs_to :room, :foreign_key => [:dorm_id, :room_id], :primary_key => [:dorm_id, :room_id]
5
+ validates_uniqueness_of :student_id
6
+
7
+ before_destroy do |record|
8
+ puts record
9
+ end
10
+
11
+ after_destroy do |record|
12
+ puts record
13
+ end
14
14
  end
@@ -1,24 +1,24 @@
1
- jacksons_room:
2
- student_id: 1
3
- dorm_id: 1
4
- room_id: 1
5
-
6
- bobs_room:
7
- student_id: 2
8
- dorm_id: 1
9
- room_id: 1
10
-
11
- kellys_room:
12
- student_id: 3
13
- dorm_id: 1
14
- room_id: 2
15
-
16
- jordans_room:
17
- student_id: 4
18
- dorm_id: 1
19
- room_id: 2
20
-
21
- brads_room:
22
- student_id: 5
23
- dorm_id: 1
24
- room_id: 3
1
+ jacksons_room:
2
+ student_id: 1
3
+ dorm_id: 1
4
+ room_id: 1
5
+
6
+ bobs_room:
7
+ student_id: 2
8
+ dorm_id: 1
9
+ room_id: 1
10
+
11
+ kellys_room:
12
+ student_id: 3
13
+ dorm_id: 1
14
+ room_id: 2
15
+
16
+ jordans_room:
17
+ student_id: 4
18
+ dorm_id: 1
19
+ room_id: 2
20
+
21
+ brads_room:
22
+ student_id: 5
23
+ dorm_id: 1
24
+ room_id: 3
@@ -1,3 +1,3 @@
1
- class RoomAttribute < ActiveRecord::Base
2
- has_many :rooms, :through => :room_attribute_assignments, :foreign_key => [:dorm_id, :room_id]
1
+ class RoomAttribute < ActiveRecord::Base
2
+ has_many :rooms, :through => :room_attribute_assignments, :foreign_key => [:dorm_id, :room_id]
3
3
  end
@@ -1,5 +1,5 @@
1
- class RoomAttributeAssignment < ActiveRecord::Base
2
- self.primary_keys = :dorm_id, :room_id, :room_attribute_id
3
- belongs_to :room, :foreign_key => [:dorm_id, :room_id]
4
- belongs_to :room_attribute
1
+ class RoomAttributeAssignment < ActiveRecord::Base
2
+ self.primary_keys = :dorm_id, :room_id, :room_attribute_id
3
+ belongs_to :room, :foreign_key => [:dorm_id, :room_id]
4
+ belongs_to :room_attribute
5
5
  end