composite_primary_keys 9.0.4 → 9.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +20 -0
  3. data/Rakefile +37 -34
  4. data/lib/composite_primary_keys.rb +5 -10
  5. data/lib/composite_primary_keys/arel/in.rb +6 -6
  6. data/lib/composite_primary_keys/arel/sqlserver.rb +36 -0
  7. data/lib/composite_primary_keys/associations/association_scope.rb +51 -29
  8. data/lib/composite_primary_keys/attribute_methods/read.rb +3 -1
  9. data/lib/composite_primary_keys/connection_adapters/abstract_mysql_adapter.rb +22 -0
  10. data/lib/composite_primary_keys/relation.rb +30 -0
  11. data/lib/composite_primary_keys/relation/query_methods.rb +25 -36
  12. data/lib/composite_primary_keys/sanitization.rb +31 -47
  13. data/lib/composite_primary_keys/version.rb +1 -1
  14. data/tasks/databases/mysql.rake +40 -42
  15. data/tasks/databases/oracle.rake +29 -15
  16. data/tasks/databases/postgresql.rake +38 -47
  17. data/tasks/databases/sqlite.rake +25 -0
  18. data/tasks/databases/sqlserver.rake +32 -16
  19. data/test/abstract_unit.rb +12 -11
  20. data/test/connections/connection_spec.rb +27 -18
  21. data/test/connections/databases.ci.yml +5 -4
  22. data/test/connections/databases.example.yml +19 -4
  23. data/test/connections/databases.yml +25 -4
  24. data/test/fixtures/article.rb +6 -5
  25. data/test/fixtures/db_definitions/mysql.sql +16 -7
  26. data/test/fixtures/db_definitions/oracle.drop.sql +2 -0
  27. data/test/fixtures/db_definitions/oracle.sql +25 -15
  28. data/test/fixtures/db_definitions/postgresql.sql +11 -2
  29. data/test/fixtures/db_definitions/sqlite.sql +8 -0
  30. data/test/fixtures/db_definitions/sqlserver.sql +19 -33
  31. data/test/fixtures/pk_called_id.rb +5 -0
  32. data/test/fixtures/pk_called_ids.yml +11 -0
  33. data/test/test_associations.rb +334 -332
  34. data/test/test_create.rb +9 -1
  35. data/test/test_delete.rb +17 -39
  36. data/test/test_ids.rb +113 -109
  37. data/test/test_preload.rb +94 -0
  38. data/test/test_suite.rb +1 -1
  39. data/test/test_update.rb +12 -7
  40. metadata +14 -24
  41. data/lib/composite_primary_keys/associations/singular_association.rb +0 -14
  42. data/lib/composite_primary_keys/connection_adapters/abstract/connection_specification_changes.rb +0 -71
  43. data/lib/composite_primary_keys/connection_adapters/postgresql_adapter.rb +0 -50
  44. data/lib/composite_primary_keys/dirty.rb +0 -19
  45. data/lib/composite_primary_keys/validations/uniqueness.rb +0 -41
  46. data/tasks/databases/oracle_enhanced.rake +0 -27
  47. data/tasks/databases/sqlite3.rake +0 -27
  48. data/test/connections/native_ibm_db/connection.rb +0 -19
  49. data/test/connections/native_mysql/connection.rb +0 -17
  50. data/test/connections/native_oracle/connection.rb +0 -11
  51. data/test/connections/native_oracle_enhanced/connection.rb +0 -16
  52. data/test/connections/native_postgresql/connection.rb +0 -13
  53. data/test/connections/native_sqlite3/connection.rb +0 -9
  54. data/test/connections/native_sqlserver/connection.rb +0 -11
  55. data/test/fixtures/db_definitions/sqlserver.drop.sql +0 -92
  56. data/test/test_delete_all.rb +0 -29
@@ -1,11 +0,0 @@
1
- print "Using native Oracle\n"
2
-
3
- require File.join(PROJECT_ROOT, 'lib', 'composite_primary_keys')
4
-
5
- def connection_string
6
- "#{SPEC['username']}/#{SPEC['password']}@//#{SPEC['host']}:#{SPEC['port']}/#{SPEC['database']}"
7
- end
8
-
9
- # Adapter config setup in locals/database_connections.rb
10
- SPEC = CompositePrimaryKeys::ConnectionSpec['oracle']
11
- ActiveRecord::Base.establish_connection(SPEC)
@@ -1,16 +0,0 @@
1
- print "Using native Oracle Enhanced\n"
2
-
3
- require File.join(PROJECT_ROOT, 'lib', 'composite_primary_keys')
4
-
5
- def connection_string
6
- "#{SPEC['username']}/#{SPEC['password']}@//#{SPEC['host']}:#{SPEC['port']}/#{SPEC['database']}"
7
- end
8
-
9
- # Adapter config setup in locals/database_connections.rb
10
- SPEC = CompositePrimaryKeys::ConnectionSpec[:oracle_enhanced]
11
- ActiveRecord::Base.establish_connection(SPEC)
12
-
13
- # Change default options for Oracle Enhanced adapter
14
- ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_dates_by_column_name = true
15
- # Change NLS_DATE_FORMAT to non-default format to verify that all tests should pass
16
- ActiveRecord::Base.connection.execute %q{alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS'}
@@ -1,13 +0,0 @@
1
- print "Using native Postgresql\n"
2
-
3
- def connection_string
4
- options = Hash.new
5
- options['U'] = SPEC['username'] if SPEC['username']
6
- options['h'] = SPEC['host'] if SPEC['host']
7
- options['p'] = SPEC['port'] if SPEC['port']
8
- options.map { |key, value| "-#{key} #{value}" }.join(" ")
9
- end
10
-
11
- # Adapter config setup in text/connections/databases.yml
12
- SPEC = CompositePrimaryKeys::ConnectionSpec['postgresql']
13
- ActiveRecord::Base.establish_connection(SPEC)
@@ -1,9 +0,0 @@
1
- print "Using native Sqlite3\n"
2
-
3
- def connection_string
4
- SPEC['database']
5
- end
6
-
7
- # Adapter config setup in text/connections/databases.yml
8
- SPEC = CompositePrimaryKeys::ConnectionSpec['sqlite3']
9
- ActiveRecord::Base.establish_connection(SPEC)
@@ -1,11 +0,0 @@
1
- print "Using native SQL Server\n"
2
-
3
- require File.join(PROJECT_ROOT, 'lib', 'composite_primary_keys')
4
-
5
- def connection_string
6
- "-S #{SPEC['host']} -U #{SPEC['username']} -P\"#{SPEC['password']}\""
7
- end
8
-
9
- # Adapter config setup in locals/database_connections.rb
10
- SPEC = CompositePrimaryKeys::ConnectionSpec['sqlserver']
11
- ActiveRecord::Base.establish_connection(SPEC)
@@ -1,92 +0,0 @@
1
- USE [composite_primary_keys_unittest];
2
- go
3
-
4
- DROP TABLE topics;
5
- go
6
-
7
- DROP TABLE topic_sources;
8
- go
9
-
10
- DROP TABLE reference_types;
11
- go
12
-
13
- DROP TABLE reference_codes;
14
- go
15
-
16
- DROP TABLE products;
17
- go
18
-
19
- DROP TABLE tariffs;
20
- go
21
-
22
- DROP TABLE product_tariffs;
23
- go
24
-
25
- DROP TABLE suburbs;
26
- go
27
-
28
- DROP TABLE streets;
29
- go
30
-
31
- DROP TABLE users;
32
- go
33
-
34
- DROP TABLE articles;
35
- go
36
-
37
- DROP TABLE readings;
38
- go
39
-
40
- DROP TABLE groups;
41
- go
42
-
43
- DROP TABLE memberships;
44
- go
45
-
46
- DROP TABLE membership_statuses;
47
- go
48
-
49
- DROP TABLE departments;
50
- go
51
-
52
- DROP TABLE employees;
53
- go
54
-
55
- DROP TABLE comments;
56
- go
57
-
58
- DROP TABLE hacks;
59
- go
60
-
61
- DROP TABLE restaurants;
62
- go
63
-
64
- DROP TABLE restaurants_suburbs;
65
- go
66
-
67
- DROP TABLE dorms;
68
- go
69
-
70
- DROP TABLE rooms;
71
- go
72
-
73
- DROP TABLE room_attributes;
74
- go
75
-
76
- DROP TABLE room_attribute_assignments;
77
- go
78
-
79
- DROP TABLE students;
80
- go
81
-
82
- DROP TABLE room_assignments;
83
- go
84
-
85
- DROP TABLE seats;
86
- go
87
-
88
- DROP TABLE capitols;
89
- go
90
-
91
- DROP TABLE products_restaurants;
92
- go
@@ -1,29 +0,0 @@
1
- require File.expand_path('../abstract_unit', __FILE__)
2
-
3
- class EmployeesGroup < ActiveRecord::Base
4
-
5
- end
6
-
7
- class TestValidations < ActiveSupport::TestCase
8
- fixtures :employees
9
-
10
- def test_delete_for_model_without_primary_key
11
- EmployeesGroup.create(employee_id: 1, group_id: 100)
12
- EmployeesGroup.create(employee_id: 2, group_id: 102)
13
- EmployeesGroup.create(employee_id: 3, group_id: 103)
14
-
15
- assert_equal(EmployeesGroup.all.size, 3)
16
- exception = assert_raises(NoMethodError) {
17
- EmployeesGroup.where(employee_id: 1).first.destroy
18
- }
19
-
20
- assert(/undefined method `to_sym' for nil:NilClass/ =~ exception.message)
21
-
22
- assert(EmployeesGroup.all.size == 3)
23
- end
24
-
25
- # This test fails, requires fixin arel
26
- #def test_delete_all_with_joins
27
- # ReferenceCode.joins(:reference_type).where(:reference_type_id => 1).delete_all
28
- #end
29
- end