tyler-composite_primary_keys 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +156 -0
- data/Manifest.txt +122 -0
- data/README.txt +41 -0
- data/README_DB2.txt +33 -0
- data/lib/adapter_helper/base.rb +63 -0
- data/lib/adapter_helper/mysql.rb +13 -0
- data/lib/adapter_helper/oracle.rb +12 -0
- data/lib/adapter_helper/oracle_enhanced.rb +12 -0
- data/lib/adapter_helper/postgresql.rb +13 -0
- data/lib/adapter_helper/sqlite3.rb +13 -0
- data/lib/composite_primary_keys.rb +55 -0
- data/lib/composite_primary_keys/association_preload.rb +253 -0
- data/lib/composite_primary_keys/associations.rb +428 -0
- data/lib/composite_primary_keys/attribute_methods.rb +84 -0
- data/lib/composite_primary_keys/base.rb +344 -0
- data/lib/composite_primary_keys/calculations.rb +69 -0
- data/lib/composite_primary_keys/composite_arrays.rb +30 -0
- data/lib/composite_primary_keys/connection_adapters/abstract_adapter.rb +9 -0
- data/lib/composite_primary_keys/connection_adapters/ibm_db_adapter.rb +21 -0
- data/lib/composite_primary_keys/connection_adapters/oracle_adapter.rb +15 -0
- data/lib/composite_primary_keys/connection_adapters/oracle_enhanced_adapter.rb +17 -0
- data/lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb +53 -0
- data/lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb +15 -0
- data/lib/composite_primary_keys/fixtures.rb +8 -0
- data/lib/composite_primary_keys/migration.rb +20 -0
- data/lib/composite_primary_keys/reflection.rb +19 -0
- data/lib/composite_primary_keys/version.rb +8 -0
- data/local/database_connections.rb.sample +10 -0
- data/local/paths.rb.sample +2 -0
- data/local/tasks.rb.sample +2 -0
- data/scripts/console.rb +48 -0
- data/scripts/txt2html +67 -0
- data/scripts/txt2js +59 -0
- data/tasks/activerecord_selection.rake +43 -0
- data/tasks/databases.rake +12 -0
- data/tasks/databases/mysql.rake +30 -0
- data/tasks/databases/oracle.rake +25 -0
- data/tasks/databases/postgresql.rake +26 -0
- data/tasks/databases/sqlite3.rake +28 -0
- data/tasks/deployment.rake +22 -0
- data/tasks/local_setup.rake +13 -0
- data/tasks/website.rake +18 -0
- data/test/README_tests.txt +67 -0
- data/test/abstract_unit.rb +94 -0
- data/test/connections/native_ibm_db/connection.rb +23 -0
- data/test/connections/native_mysql/connection.rb +13 -0
- data/test/connections/native_oracle/connection.rb +14 -0
- data/test/connections/native_oracle_enhanced/connection.rb +20 -0
- data/test/connections/native_postgresql/connection.rb +9 -0
- data/test/connections/native_sqlite/connection.rb +9 -0
- data/test/fixtures/article.rb +5 -0
- data/test/fixtures/article_group.rb +4 -0
- data/test/fixtures/article_groups.yml +7 -0
- data/test/fixtures/articles.yml +6 -0
- data/test/fixtures/comment.rb +6 -0
- data/test/fixtures/comments.yml +16 -0
- data/test/fixtures/db_definitions/db2-create-tables.sql +113 -0
- data/test/fixtures/db_definitions/db2-drop-tables.sql +16 -0
- data/test/fixtures/db_definitions/mysql.sql +174 -0
- data/test/fixtures/db_definitions/oracle.drop.sql +39 -0
- data/test/fixtures/db_definitions/oracle.sql +188 -0
- data/test/fixtures/db_definitions/postgresql.sql +199 -0
- data/test/fixtures/db_definitions/sqlite.sql +160 -0
- data/test/fixtures/department.rb +5 -0
- data/test/fixtures/departments.yml +3 -0
- data/test/fixtures/dorm.rb +3 -0
- data/test/fixtures/dorms.yml +2 -0
- data/test/fixtures/employee.rb +4 -0
- data/test/fixtures/employees.yml +9 -0
- data/test/fixtures/group.rb +3 -0
- data/test/fixtures/groups.yml +3 -0
- data/test/fixtures/hack.rb +6 -0
- data/test/fixtures/hacks.yml +2 -0
- data/test/fixtures/kitchen_sink.rb +3 -0
- data/test/fixtures/kitchen_sinks.yml +5 -0
- data/test/fixtures/membership.rb +7 -0
- data/test/fixtures/membership_status.rb +3 -0
- data/test/fixtures/membership_statuses.yml +10 -0
- data/test/fixtures/memberships.yml +6 -0
- data/test/fixtures/product.rb +7 -0
- data/test/fixtures/product_tariff.rb +5 -0
- data/test/fixtures/product_tariffs.yml +12 -0
- data/test/fixtures/products.yml +6 -0
- data/test/fixtures/reading.rb +4 -0
- data/test/fixtures/readings.yml +10 -0
- data/test/fixtures/reference_code.rb +7 -0
- data/test/fixtures/reference_codes.yml +28 -0
- data/test/fixtures/reference_type.rb +7 -0
- data/test/fixtures/reference_types.yml +9 -0
- data/test/fixtures/restaurant.rb +6 -0
- data/test/fixtures/restaurants.yml +5 -0
- data/test/fixtures/restaurants_suburbs.yml +11 -0
- data/test/fixtures/room.rb +10 -0
- data/test/fixtures/room_assignment.rb +4 -0
- data/test/fixtures/room_assignments.yml +4 -0
- data/test/fixtures/room_attribute.rb +3 -0
- data/test/fixtures/room_attribute_assignment.rb +5 -0
- data/test/fixtures/room_attribute_assignments.yml +4 -0
- data/test/fixtures/room_attributes.yml +3 -0
- data/test/fixtures/rooms.yml +3 -0
- data/test/fixtures/street.rb +3 -0
- data/test/fixtures/streets.yml +15 -0
- data/test/fixtures/student.rb +4 -0
- data/test/fixtures/students.yml +2 -0
- data/test/fixtures/suburb.rb +6 -0
- data/test/fixtures/suburbs.yml +9 -0
- data/test/fixtures/tariff.rb +6 -0
- data/test/fixtures/tariffs.yml +13 -0
- data/test/fixtures/user.rb +10 -0
- data/test/fixtures/users.yml +6 -0
- data/test/hash_tricks.rb +34 -0
- data/test/plugins/pagination.rb +405 -0
- data/test/plugins/pagination_helper.rb +135 -0
- data/test/test_associations.rb +160 -0
- data/test/test_attribute_methods.rb +22 -0
- data/test/test_attributes.rb +84 -0
- data/test/test_clone.rb +34 -0
- data/test/test_composite_arrays.rb +51 -0
- data/test/test_create.rb +68 -0
- data/test/test_delete.rb +96 -0
- data/test/test_dummy.rb +28 -0
- data/test/test_exists.rb +29 -0
- data/test/test_find.rb +73 -0
- data/test/test_ids.rb +97 -0
- data/test/test_miscellaneous.rb +39 -0
- data/test/test_pagination.rb +38 -0
- data/test/test_polymorphic.rb +31 -0
- data/test/test_santiago.rb +27 -0
- data/test/test_tutorial_examle.rb +26 -0
- data/test/test_update.rb +40 -0
- metadata +196 -0
data/History.txt
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
== 2.2.1 2009-01-21
|
2
|
+
|
3
|
+
* fix ActiveRecord#exists? to work when passing conditions instead of ids
|
4
|
+
|
5
|
+
== 2.2.0 2008-10-29
|
6
|
+
|
7
|
+
* Rails 2.2.0 compatibility
|
8
|
+
|
9
|
+
== 1.1.0 2008-10-29
|
10
|
+
|
11
|
+
* fixes to get cpk working for Rails 2.1.2
|
12
|
+
|
13
|
+
== 1.0.10 2008-10-22
|
14
|
+
|
15
|
+
* add composite key where clause creator method [timurv]
|
16
|
+
|
17
|
+
== 1.0.9 2008-09-08
|
18
|
+
|
19
|
+
* fix postgres tests
|
20
|
+
* fix for delete_records when has_many association has composite keys [darxriggs]
|
21
|
+
* more consistent table/column name quoting [pbrant]
|
22
|
+
|
23
|
+
== 1.0.8 2008-08-27
|
24
|
+
|
25
|
+
* fix has_many :through for non composite models [thx rcarver]
|
26
|
+
|
27
|
+
== 1.0.7 2008-08-12
|
28
|
+
|
29
|
+
* fix for the last fix -- when has_many is composite and belongs_to is single
|
30
|
+
|
31
|
+
== 1.0.6 2008-08-06
|
32
|
+
|
33
|
+
* fix associations create
|
34
|
+
|
35
|
+
== 1.0.5 2008-07-25
|
36
|
+
|
37
|
+
* fix for calculations with a group by clause [thx Sirius Black]
|
38
|
+
|
39
|
+
== 1.0.4 2008-07-15
|
40
|
+
|
41
|
+
* support for oracle_enhanced adapter [thx Raimonds Simanovskis]
|
42
|
+
|
43
|
+
== 1.0.3 2008-07-13
|
44
|
+
|
45
|
+
* more fixes and tests for has many through [thx Menno van der Sman]
|
46
|
+
|
47
|
+
== 1.0.2 2008-06-07
|
48
|
+
|
49
|
+
* fix for has many through when through association has composite keys
|
50
|
+
|
51
|
+
== 1.0.1 2008-06-06
|
52
|
+
|
53
|
+
* Oracle fixes
|
54
|
+
|
55
|
+
== 1.0.0 2008-06-05
|
56
|
+
|
57
|
+
* Support for Rails 2.1
|
58
|
+
|
59
|
+
== 0.9.93 2008-06-01
|
60
|
+
|
61
|
+
* set fixed dependency on activerecord 2.0.2
|
62
|
+
|
63
|
+
== 0.9.92 2008-02-22
|
64
|
+
|
65
|
+
* Support for has_and_belongs_to_many
|
66
|
+
|
67
|
+
== 0.9.91 2008-01-27
|
68
|
+
|
69
|
+
* Incremented activerecord dependency to 2.0.2 [thx emmanuel.pirsch]
|
70
|
+
|
71
|
+
== 0.9.90 2008-01-27
|
72
|
+
|
73
|
+
* Trial release for rails/activerecord 2.0.2 supported
|
74
|
+
|
75
|
+
== 0.9.1 2007-10-28
|
76
|
+
|
77
|
+
* Migrations fix - allow :primary_key => [:name] to work [no unit test] [thx Shugo Maeda]
|
78
|
+
|
79
|
+
== 0.9.0 2007-09-28
|
80
|
+
|
81
|
+
* Added support for polymorphs [thx nerdrew]
|
82
|
+
* init.rb file so gem can be installed as a plugin for Rails [thx nerdrew]
|
83
|
+
* Added ibm_db support [thx K Venkatasubramaniyan]
|
84
|
+
* Support for cleaning dependents [thx K Venkatasubramaniyan]
|
85
|
+
* Rafactored db rake tasks into namespaces
|
86
|
+
* Added namespaced tests (e.g. mysql:test for test_mysql)
|
87
|
+
|
88
|
+
== 0.8.6 / 2007-6-12
|
89
|
+
|
90
|
+
* 1 emergency fix due to Rails Core change
|
91
|
+
* Rails v7004 removed #quote; fixed with connection.quote_column_name [thx nerdrew]
|
92
|
+
|
93
|
+
== 0.8.5 / 2007-6-5
|
94
|
+
|
95
|
+
* 1 change due to Rails Core change
|
96
|
+
* Can no longer use RAILS_CONNECTION_ADAPTERS from Rails core
|
97
|
+
* 7 dev improvement:
|
98
|
+
* Changed History.txt syntax to rdoc format
|
99
|
+
* Added deploy tasks
|
100
|
+
* Removed CHANGELOG + migrated into History.txt
|
101
|
+
* Changed PKG_NAME -> GEM_NAME in Rakefile
|
102
|
+
* Renamed README -> README.txt for :publish_docs task
|
103
|
+
* Added :check_version task
|
104
|
+
* VER => VERS in rakefile
|
105
|
+
* 1 website improvement:
|
106
|
+
* website/index.txt includes link to "8 steps to fix other ppls code"
|
107
|
+
|
108
|
+
== 0.8.4 / 2007-5-3
|
109
|
+
|
110
|
+
* 1 bugfix
|
111
|
+
* Corrected ids_list => ids in the exception message. That'll teach me for not adding unit tests before fixing bugs.
|
112
|
+
|
113
|
+
== 0.8.3 / 2007-5-3
|
114
|
+
|
115
|
+
* 1 bugfix
|
116
|
+
* Explicit reference to ::ActiveRecord::RecordNotFound
|
117
|
+
* 1 website addition:
|
118
|
+
* Added routing help [Pete Sumskas]
|
119
|
+
|
120
|
+
== 0.8.2 / 2007-4-11
|
121
|
+
|
122
|
+
* 1 major enhancement:
|
123
|
+
* Oracle unit tests!! [Darrin Holst]
|
124
|
+
* And they work too
|
125
|
+
|
126
|
+
== 0.8.1 / 2007-4-10
|
127
|
+
|
128
|
+
* 1 bug fix:
|
129
|
+
* Fixed the distinct(count) for oracle (removed 'as')
|
130
|
+
|
131
|
+
== 0.8.0 / 2007-4-6
|
132
|
+
|
133
|
+
* 1 major enhancement:
|
134
|
+
* Support for calcualtions on associations
|
135
|
+
* 2 new DB supported:
|
136
|
+
* Tests run on sqlite
|
137
|
+
* Tests run on postgresql
|
138
|
+
* History.txt to keep track of changes like these
|
139
|
+
* Using Hoe for Rakefile
|
140
|
+
* Website generator rake tasks
|
141
|
+
|
142
|
+
== 0.3.3
|
143
|
+
* id=
|
144
|
+
* create now work
|
145
|
+
|
146
|
+
== 0.1.4
|
147
|
+
* it was important that #{primary_key} for composites --> 'key1,key2' and not 'key1key2' so created PrimaryKeys class
|
148
|
+
|
149
|
+
== 0.0.1
|
150
|
+
* Initial version
|
151
|
+
* set_primary_keys(*keys) is the activation class method to transform an ActiveRecord into a composite primary key AR
|
152
|
+
* find(*ids) supports the passing of
|
153
|
+
* id sets: Foo.find(2,1),
|
154
|
+
* lists of id sets: Foo.find([2,1], [7,3], [8,12]),
|
155
|
+
* and even stringified versions of the above:
|
156
|
+
* Foo.find '2,1' or Foo.find '2,1;7,3'
|
data/Manifest.txt
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.txt
|
4
|
+
README_DB2.txt
|
5
|
+
Rakefile
|
6
|
+
init.rb
|
7
|
+
install.rb
|
8
|
+
lib/adapter_helper/base.rb
|
9
|
+
lib/adapter_helper/mysql.rb
|
10
|
+
lib/adapter_helper/oracle.rb
|
11
|
+
lib/adapter_helper/postgresql.rb
|
12
|
+
lib/adapter_helper/sqlite3.rb
|
13
|
+
lib/composite_primary_keys.rb
|
14
|
+
lib/composite_primary_keys/association_preload.rb
|
15
|
+
lib/composite_primary_keys/associations.rb
|
16
|
+
lib/composite_primary_keys/attribute_methods.rb
|
17
|
+
lib/composite_primary_keys/base.rb
|
18
|
+
lib/composite_primary_keys/calculations.rb
|
19
|
+
lib/composite_primary_keys/composite_arrays.rb
|
20
|
+
lib/composite_primary_keys/connection_adapters/ibm_db_adapter.rb
|
21
|
+
lib/composite_primary_keys/connection_adapters/oracle_adapter.rb
|
22
|
+
lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb
|
23
|
+
lib/composite_primary_keys/connection_adapters/sqlite3_adapter.rb
|
24
|
+
lib/composite_primary_keys/fixtures.rb
|
25
|
+
lib/composite_primary_keys/migration.rb
|
26
|
+
lib/composite_primary_keys/reflection.rb
|
27
|
+
lib/composite_primary_keys/version.rb
|
28
|
+
loader.rb
|
29
|
+
local/database_connections.rb.sample
|
30
|
+
local/paths.rb.sample
|
31
|
+
local/tasks.rb.sample
|
32
|
+
scripts/console.rb
|
33
|
+
scripts/txt2html
|
34
|
+
scripts/txt2js
|
35
|
+
tasks/activerecord_selection.rake
|
36
|
+
tasks/databases.rake
|
37
|
+
tasks/databases/mysql.rake
|
38
|
+
tasks/databases/oracle.rake
|
39
|
+
tasks/databases/postgresql.rake
|
40
|
+
tasks/databases/sqlite3.rake
|
41
|
+
tasks/deployment.rake
|
42
|
+
tasks/local_setup.rake
|
43
|
+
tasks/website.rake
|
44
|
+
test/README_tests.txt
|
45
|
+
test/abstract_unit.rb
|
46
|
+
test/connections/native_ibm_db/connection.rb
|
47
|
+
test/connections/native_mysql/connection.rb
|
48
|
+
test/connections/native_oracle/connection.rb
|
49
|
+
test/connections/native_postgresql/connection.rb
|
50
|
+
test/connections/native_sqlite/connection.rb
|
51
|
+
test/fixtures/article.rb
|
52
|
+
test/fixtures/articles.yml
|
53
|
+
test/fixtures/comment.rb
|
54
|
+
test/fixtures/comments.yml
|
55
|
+
test/fixtures/db_definitions/db2-create-tables.sql
|
56
|
+
test/fixtures/db_definitions/db2-drop-tables.sql
|
57
|
+
test/fixtures/db_definitions/mysql.sql
|
58
|
+
test/fixtures/db_definitions/oracle.drop.sql
|
59
|
+
test/fixtures/db_definitions/oracle.sql
|
60
|
+
test/fixtures/db_definitions/postgresql.sql
|
61
|
+
test/fixtures/db_definitions/sqlite.sql
|
62
|
+
test/fixtures/department.rb
|
63
|
+
test/fixtures/departments.yml
|
64
|
+
test/fixtures/employee.rb
|
65
|
+
test/fixtures/employees.yml
|
66
|
+
test/fixtures/group.rb
|
67
|
+
test/fixtures/groups.yml
|
68
|
+
test/fixtures/hack.rb
|
69
|
+
test/fixtures/hacks.yml
|
70
|
+
test/fixtures/membership.rb
|
71
|
+
test/fixtures/membership_status.rb
|
72
|
+
test/fixtures/membership_statuses.yml
|
73
|
+
test/fixtures/memberships.yml
|
74
|
+
test/fixtures/product.rb
|
75
|
+
test/fixtures/product_tariff.rb
|
76
|
+
test/fixtures/product_tariffs.yml
|
77
|
+
test/fixtures/products.yml
|
78
|
+
test/fixtures/reading.rb
|
79
|
+
test/fixtures/readings.yml
|
80
|
+
test/fixtures/reference_code.rb
|
81
|
+
test/fixtures/reference_codes.yml
|
82
|
+
test/fixtures/reference_type.rb
|
83
|
+
test/fixtures/reference_types.yml
|
84
|
+
test/fixtures/street.rb
|
85
|
+
test/fixtures/streets.yml
|
86
|
+
test/fixtures/suburb.rb
|
87
|
+
test/fixtures/suburbs.yml
|
88
|
+
test/fixtures/tariff.rb
|
89
|
+
test/fixtures/tariffs.yml
|
90
|
+
test/fixtures/user.rb
|
91
|
+
test/fixtures/users.yml
|
92
|
+
test/hash_tricks.rb
|
93
|
+
test/plugins/pagination.rb
|
94
|
+
test/plugins/pagination_helper.rb
|
95
|
+
test/test_associations.rb
|
96
|
+
test/test_attribute_methods.rb
|
97
|
+
test/test_attributes.rb
|
98
|
+
test/test_clone.rb
|
99
|
+
test/test_composite_arrays.rb
|
100
|
+
test/test_create.rb
|
101
|
+
test/test_delete.rb
|
102
|
+
test/test_dummy.rb
|
103
|
+
test/test_exists.rb
|
104
|
+
test/test_find.rb
|
105
|
+
test/test_ids.rb
|
106
|
+
test/test_miscellaneous.rb
|
107
|
+
test/test_pagination.rb
|
108
|
+
test/test_polymorphic.rb
|
109
|
+
test/test_santiago.rb
|
110
|
+
test/test_tutorial_examle.rb
|
111
|
+
test/test_update.rb
|
112
|
+
tmp/test.db
|
113
|
+
website/index.html
|
114
|
+
website/index.txt
|
115
|
+
website/javascripts/rounded_corners_lite.inc.js
|
116
|
+
website/stylesheets/screen.css
|
117
|
+
website/template.js
|
118
|
+
website/template.rhtml
|
119
|
+
website/version-raw.js
|
120
|
+
website/version-raw.txt
|
121
|
+
website/version.js
|
122
|
+
website/version.txt
|
data/README.txt
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
= Composite Primary Keys for ActiveRecords
|
2
|
+
|
3
|
+
== Summary
|
4
|
+
|
5
|
+
ActiveRecords/Rails famously doesn't support composite primary keys.
|
6
|
+
This RubyGem extends the activerecord gem to provide CPK support.
|
7
|
+
|
8
|
+
== Installation
|
9
|
+
|
10
|
+
gem install composite_primary_keys
|
11
|
+
|
12
|
+
== Usage
|
13
|
+
|
14
|
+
require 'composite_primary_keys'
|
15
|
+
class ProductVariation
|
16
|
+
set_primary_keys :product_id, :variation_seq
|
17
|
+
end
|
18
|
+
|
19
|
+
pv = ProductVariation.find(345, 12)
|
20
|
+
|
21
|
+
It even supports composite foreign keys for associations.
|
22
|
+
|
23
|
+
See http://compositekeys.rubyforge.org for more.
|
24
|
+
|
25
|
+
== Running Tests
|
26
|
+
|
27
|
+
See test/README.tests.txt
|
28
|
+
|
29
|
+
== Url
|
30
|
+
|
31
|
+
http://compositekeys.rubyforge.org
|
32
|
+
|
33
|
+
== Questions, Discussion and Contributions
|
34
|
+
|
35
|
+
http://groups.google.com/compositekeys
|
36
|
+
|
37
|
+
== Author
|
38
|
+
|
39
|
+
Written by Dr Nic Williams, drnicwilliams@gmail
|
40
|
+
Contributions by many!
|
41
|
+
|
data/README_DB2.txt
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
Composite Primary key support for db2
|
2
|
+
|
3
|
+
== Driver Support ==
|
4
|
+
|
5
|
+
DB2 support requires the IBM_DB driver provided by http://rubyforge.org/projects/rubyibm/
|
6
|
+
project. Install using gem install ibm_db. Tested against version 0.60 of the driver.
|
7
|
+
This rubyforge project appears to be permenant location for the IBM adapter.
|
8
|
+
Older versions of the driver available from IBM Alphaworks will not work.
|
9
|
+
|
10
|
+
== Driver Bug and workaround provided as part of this plugin ==
|
11
|
+
|
12
|
+
Unlike the basic quote routine available for Rails AR, the DB2 adapter's quote
|
13
|
+
method doesn't return " column_name = 1 " when string values (integers in string type variable)
|
14
|
+
are passed for quoting numeric column. Rather it returns "column_name = '1'.
|
15
|
+
DB2 doesn't accept single quoting numeric columns in SQL. Currently, as part of
|
16
|
+
this plugin a fix is provided for the DB2 adapter since this plugin does
|
17
|
+
pass string values like this. Perhaps a patch should be sent to the DB2 adapter
|
18
|
+
project for a permanant fix.
|
19
|
+
|
20
|
+
== Database Setup ==
|
21
|
+
|
22
|
+
Database must be manually created using a separate command. Read the rake task
|
23
|
+
for creating tables and change the db name, user and passwords accordingly.
|
24
|
+
|
25
|
+
== Tested Database Server version ==
|
26
|
+
|
27
|
+
This is tested against DB2 v9.1 in Ubuntu Feisty Fawn (7.04)
|
28
|
+
|
29
|
+
== Tested Database Client version ==
|
30
|
+
|
31
|
+
This is tested against DB2 v9.1 in Ubuntu Feisty Fawn (7.04)
|
32
|
+
|
33
|
+
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module AdapterHelper
|
2
|
+
class Base
|
3
|
+
class << self
|
4
|
+
attr_accessor :adapter
|
5
|
+
|
6
|
+
def load_connection_from_env(adapter)
|
7
|
+
self.adapter = adapter
|
8
|
+
unless ENV['cpk_adapters']
|
9
|
+
puts error_msg_setup_helper
|
10
|
+
exit
|
11
|
+
end
|
12
|
+
|
13
|
+
ActiveRecord::Base.configurations = YAML.load(ENV['cpk_adapters'])
|
14
|
+
unless spec = ActiveRecord::Base.configurations[adapter]
|
15
|
+
puts error_msg_adapter_helper
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
spec[:adapter] = adapter
|
19
|
+
spec
|
20
|
+
end
|
21
|
+
|
22
|
+
def error_msg_setup_helper
|
23
|
+
<<-EOS
|
24
|
+
Setup Helper:
|
25
|
+
CPK now has a place for your individual testing configuration.
|
26
|
+
That is, instead of hardcoding it in the Rakefile and test/connections files,
|
27
|
+
there is now a local/database_connections.rb file that is NOT in the
|
28
|
+
repository. Your personal DB information (username, password etc) can
|
29
|
+
be stored here without making it difficult to submit patches etc.
|
30
|
+
|
31
|
+
Installation:
|
32
|
+
i) cp locals/database_connections.rb.sample locals/database_connections.rb
|
33
|
+
ii) For #{adapter} connection details see "Adapter Setup Helper" below.
|
34
|
+
iii) Rerun this task
|
35
|
+
|
36
|
+
#{error_msg_adapter_helper}
|
37
|
+
|
38
|
+
Current ENV:
|
39
|
+
#{ENV.inspect}
|
40
|
+
EOS
|
41
|
+
end
|
42
|
+
|
43
|
+
def error_msg_adapter_helper
|
44
|
+
<<-EOS
|
45
|
+
Adapter Setup Helper:
|
46
|
+
To run #{adapter} tests, you need to setup your #{adapter} connections.
|
47
|
+
In your local/database_connections.rb file, within the ENV['cpk_adapter'] hash, add:
|
48
|
+
"#{adapter}" => { adapter settings }
|
49
|
+
|
50
|
+
That is, it will look like:
|
51
|
+
ENV['cpk_adapters'] = {
|
52
|
+
"#{adapter}" => {
|
53
|
+
:adapter => "#{adapter}",
|
54
|
+
:username => "root",
|
55
|
+
:password => "root",
|
56
|
+
# ...
|
57
|
+
}
|
58
|
+
}.to_yaml
|
59
|
+
EOS
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'base')
|
2
|
+
|
3
|
+
module AdapterHelper
|
4
|
+
class MySQL < Base
|
5
|
+
class << self
|
6
|
+
def load_connection_from_env
|
7
|
+
spec = super('mysql')
|
8
|
+
spec[:database] ||= 'composite_primary_keys_unittest'
|
9
|
+
spec
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|