composite_primary_keys 14.0.5 → 14.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/History.rdoc +21 -0
  3. data/Rakefile +1 -1
  4. data/lib/composite_primary_keys/associations/association.rb +2 -2
  5. data/lib/composite_primary_keys/associations/association_scope.rb +1 -1
  6. data/lib/composite_primary_keys/associations/has_many_through_association.rb +19 -0
  7. data/lib/composite_primary_keys/associations/preloader/association.rb +0 -16
  8. data/lib/composite_primary_keys/connection_adapters/abstract/database_statements.rb +1 -2
  9. data/lib/composite_primary_keys/relation/query_methods.rb +14 -16
  10. data/lib/composite_primary_keys/relation.rb +4 -2
  11. data/lib/composite_primary_keys/version.rb +1 -1
  12. data/lib/composite_primary_keys.rb +117 -119
  13. data/scripts/console.rb +2 -2
  14. data/tasks/databases/trilogy.rake +23 -0
  15. data/test/abstract_unit.rb +124 -118
  16. data/test/connections/databases.ci.yml +10 -0
  17. data/test/fixtures/admin.rb +4 -0
  18. data/test/fixtures/comments.yml +6 -0
  19. data/test/fixtures/db_definitions/db2-create-tables.sql +34 -0
  20. data/test/fixtures/db_definitions/db2-drop-tables.sql +7 -1
  21. data/test/fixtures/db_definitions/mysql.sql +23 -0
  22. data/test/fixtures/db_definitions/oracle.drop.sql +4 -0
  23. data/test/fixtures/db_definitions/oracle.sql +21 -0
  24. data/test/fixtures/db_definitions/postgresql.sql +23 -0
  25. data/test/fixtures/db_definitions/sqlite.sql +21 -0
  26. data/test/fixtures/db_definitions/sqlserver.sql +23 -0
  27. data/test/fixtures/moderator.rb +4 -0
  28. data/test/fixtures/room.rb +4 -1
  29. data/test/fixtures/staff_room.rb +6 -0
  30. data/test/fixtures/staff_room_key.rb +6 -0
  31. data/test/fixtures/user.rb +3 -0
  32. data/test/fixtures/user_with_polymorphic_name.rb +9 -0
  33. data/test/test_associations.rb +403 -403
  34. data/test/test_has_one_through.rb +30 -0
  35. data/test/test_polymorphic.rb +6 -0
  36. metadata +11 -4
  37. data/lib/composite_primary_keys/associations/through_association.rb +0 -24
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4feff3a4f8ce272695c7a081666b99f3e9b79b206dce5acf9728c0c2c0cb2d9a
4
- data.tar.gz: f5d7533a624427d056ad9fd7576242a2b6318ed584939bea834de44bd8d618af
3
+ metadata.gz: de97dfff0f237f22dd32a32189824739087b30c0ea0e14cdd996bd8b69359caf
4
+ data.tar.gz: 722a9e0d02b6fa8ee2010d47e5a37705a43b302df6abf7c7a6d199b0a84b0201
5
5
  SHA512:
6
- metadata.gz: a2e52091afe3577f46df1e0093ad6d4d6167a250e27ec7776af7706b8ec01fce0539f15a0bcaa1d12273ac2ed8055cddcc6fef5536b5e7ae8761d4158c2f9a6a
7
- data.tar.gz: 8159181dd45c05ba6aad2a57ff482bdf8471904d6990517e04a992bc177e42b5cb201dfb48ff7e645ecfb2e23270ed129a9a6666b87a6412d07a3163200e4d72
6
+ metadata.gz: e57b5330dc2b0cdb7374f14ed6c7efed22c269cf42298527efc1ec26ee2e2ea8ab9edd97e97a7f4c656662e54a1faa5da28fef365c602060878d375e4caa646a
7
+ data.tar.gz: c2981385774399cdd3e64385d9f7595dd2a3972706b04e825b604f83ed4fe59438df2f114f196ff0fb6ceb389060554259cab7132c2a75073a382101da533bd0
data/History.rdoc CHANGED
@@ -1,3 +1,13 @@
1
+ == 14.0.7 (2023-11-04)
2
+ * Add support for Trilogy Adapter (Zack Mariscal)
3
+ * Add Dockerfile and Docker compose support (Zack Mariscal)
4
+ * Support polymorphic_name (Vladimir Kochnev)
5
+ * Fix HasOneThrough association (kyori19)
6
+
7
+ == 14.0.6 (2023-02-04)
8
+ * Port fix for #573 (Charlie Savage)
9
+ * Port fix for fix #577 (Charlie Savage)
10
+
1
11
  == 14.0.5 (2023-02-04)
2
12
  * Improve query generation for cpk_in_predicate. This reduces the length of
3
13
  queries when loading many keys and enables Postgres to use index scans
@@ -27,6 +37,17 @@ more frequently. (Andrew Kiellor)
27
37
  == 14.0.0 (2022-01-9)
28
38
  * Update to ActiveRecord 7.0 (Sammy Larbi)
29
39
 
40
+ == 13.0.7 (2023-02-04)
41
+ * Fix #573 (Charlie Savage)
42
+
43
+ == 13.0.6 (2023-02-04)
44
+ * Fix #577 (Charlie Savage)
45
+
46
+ == 13.0.5 (2023-02-04)
47
+ * Improve query generation for cpk_in_predicate. This reduces the length of
48
+ queries when loading many keys and enables Postgres to use index scans
49
+ more frequently. (Andrew Kiellor)
50
+
30
51
  == 13.0.4 (2022-12-05)
31
52
  * Fix previously_new_record? not being set to true after create (Akinori MUSHA)
32
53
 
data/Rakefile CHANGED
@@ -23,7 +23,7 @@ Dir.glob('tasks/**/*.rake').each do |rake_file|
23
23
  end
24
24
 
25
25
  # Set up test tasks for each supported connection adapter
26
- %w(mysql sqlite oracle oracle_enhanced postgresql ibm_db sqlserver).each do |adapter|
26
+ %w(mysql sqlite oracle oracle_enhanced postgresql ibm_db sqlserver trilogy).each do |adapter|
27
27
  namespace adapter do
28
28
  desc "Run tests using the #{adapter} adapter"
29
29
  task "test" do
@@ -11,8 +11,8 @@ module ActiveRecord
11
11
  attributes[key1] = owner[key2]
12
12
  end
13
13
 
14
- if reflection.options[:as]
15
- attributes[reflection.type] = owner.class.base_class.name
14
+ if reflection.type
15
+ attributes[reflection.type] = owner.class.polymorphic_name
16
16
  end
17
17
  end
18
18
 
@@ -64,4 +64,4 @@ module ActiveRecord
64
64
  end
65
65
  end
66
66
  end
67
- end
67
+ end
@@ -23,6 +23,25 @@ module ActiveRecord
23
23
  end
24
24
  end
25
25
  end
26
+
27
+ alias :original_construct_join_attributes :construct_join_attributes
28
+
29
+ def construct_join_attributes(*records)
30
+ # CPK
31
+ if !self.source_reflection.polymorphic? && source_reflection.klass.composite?
32
+ ensure_mutable
33
+
34
+ ids = records.map do |record|
35
+ source_reflection.association_primary_key(reflection.klass).map do |key|
36
+ record.send(key)
37
+ end
38
+ end
39
+
40
+ cpk_in_predicate(through_association.scope.klass.arel_table, source_reflection.foreign_key, ids)
41
+ else
42
+ original_construct_join_attributes(*records)
43
+ end
44
+ end
26
45
  end
27
46
  end
28
47
  end
@@ -46,22 +46,6 @@ module ActiveRecord
46
46
  (result[key] ||= []) << owner if key
47
47
  end
48
48
  end
49
-
50
- # TODO: is records_by_owner needed anymore? Rails' implementation has changed significantly
51
- def records_by_owner
52
- @records_by_owner ||= preloaded_records.each_with_object({}) do |record, result|
53
- key = if association_key_name.is_a?(Array)
54
- Array(record[association_key_name]).map do |key|
55
- convert_key(key)
56
- end
57
- else
58
- convert_key(record[association_key_name])
59
- end
60
- owners_by_key[key].each do |owner|
61
- (result[owner] ||= []) << record
62
- end
63
- end
64
- end
65
49
  end
66
50
  end
67
51
  end
@@ -6,8 +6,7 @@ module ActiveRecord
6
6
  value = exec_insert(sql, name, binds, pk, sequence_name)
7
7
 
8
8
  return id_value if id_value
9
-
10
- if pk.is_a?(Array) && !value.empty?
9
+ if pk.is_a?(Array) && value.respond_to?(:empty?) && !value.empty?
11
10
  # This is a CPK model and the query result is not empty. Thus we can figure out the new ids for each
12
11
  # auto incremented field
13
12
  pk.map {|key| value.first[key]}
@@ -18,23 +18,21 @@ module CompositePrimaryKeys
18
18
  end
19
19
 
20
20
  order_query.flat_map do |o|
21
- order_query.flat_map do |o|
22
- case o
23
- when Arel::Attribute
24
- o.desc
25
- when Arel::Nodes::Ordering
26
- o.reverse
27
- when String
28
- if does_not_support_reverse?(o)
29
- raise IrreversibleOrderError, "Order #{o.inspect} can not be reversed automatically"
30
- end
31
- o.split(",").map! do |s|
32
- s.strip!
33
- s.gsub!(/\sasc\Z/i, " DESC") || s.gsub!(/\sdesc\Z/i, " ASC") || (s << " DESC")
34
- end
35
- else
36
- o
21
+ case o
22
+ when Arel::Attribute
23
+ o.desc
24
+ when Arel::Nodes::Ordering
25
+ o.reverse
26
+ when String
27
+ if does_not_support_reverse?(o)
28
+ raise IrreversibleOrderError, "Order #{o.inspect} can not be reversed automatically"
37
29
  end
30
+ o.split(",").map! do |s|
31
+ s.strip!
32
+ s.gsub!(/\sasc\Z/i, " DESC") || s.gsub!(/\sdesc\Z/i, " ASC") || (s << " DESC")
33
+ end
34
+ else
35
+ o
38
36
  end
39
37
  end
40
38
  end
@@ -29,7 +29,7 @@ module ActiveRecord
29
29
  stmt.key = table[primary_key]
30
30
 
31
31
  # CPK
32
- if @klass.composite? && @klass.connection.visitor.compile(stmt.ast) =~ /['"]#{primary_key.to_s}['"]/
32
+ if @klass.composite?
33
33
  stmt = Arel::UpdateManager.new
34
34
  stmt.table(arel_table)
35
35
  cpk_subquery(stmt)
@@ -74,7 +74,7 @@ module ActiveRecord
74
74
  stmt.key = table[primary_key]
75
75
 
76
76
  # CPK
77
- if @klass.composite? && @klass.connection.visitor.compile(stmt.ast) =~ /['"]#{primary_key.to_s}['"]/
77
+ if @klass.composite?
78
78
  stmt = Arel::DeleteManager.new
79
79
  stmt.from(arel_table)
80
80
  cpk_subquery(stmt)
@@ -102,6 +102,8 @@ module ActiveRecord
102
102
  # database adapter to decide how to proceed.
103
103
  if defined?(ActiveRecord::ConnectionAdapters::Mysql2Adapter) && connection.is_a?(ActiveRecord::ConnectionAdapters::Mysql2Adapter)
104
104
  cpk_mysql_subquery(stmt)
105
+ elsif defined?(ActiveRecord::ConnectionAdapters::TrilogyAdapter) && connection.is_a?(ActiveRecord::ConnectionAdapters::TrilogyAdapter)
106
+ cpk_mysql_subquery(stmt)
105
107
  elsif defined?(ActiveRecord::ConnectionAdapters::SQLServerAdapter) && connection.is_a?(ActiveRecord::ConnectionAdapters::SQLServerAdapter)
106
108
  cpk_exists_subquery(stmt)
107
109
  else
@@ -2,7 +2,7 @@ module CompositePrimaryKeys
2
2
  module VERSION
3
3
  MAJOR = 14
4
4
  MINOR = 0
5
- TINY = 5
5
+ TINY = 7
6
6
  STRING = [MAJOR, MINOR, TINY].join('.')
7
7
  end
8
8
  end
@@ -1,119 +1,117 @@
1
- #--
2
- # Copyright (c) 2006-2016 Nic Williams and Charlie Savage
3
- #
4
- # Permission is hereby granted, free of charge, to any person obtaining
5
- # a copy of this software and associated documentation files (the
6
- # "Software"), to deal in the Software without restriction, including
7
- # without limitation the rights to use, copy, modify, merge, publish,
8
- # distribute, sublicense, and/or sell copies of the Software, and to
9
- # permit persons to whom the Software is furnished to do so, subject to
10
- # the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be
13
- # included in all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
- # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
- # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
- #++
23
-
24
- unless defined?(ActiveRecord)
25
- require 'rubygems'
26
- gem 'activerecord', '~>7.0.0', '>= 7.0.1'
27
- require 'active_record'
28
- end
29
-
30
- # ActiveModel files we override
31
- # _write_attribute
32
- require 'active_model/attribute_assignment'
33
-
34
- # ActiveRecord files we override
35
- require 'active_record/attribute_methods'
36
- require 'active_record/autosave_association'
37
- require 'active_record/counter_cache'
38
- require 'active_record/fixtures'
39
- require 'active_record/model_schema'
40
- require 'active_record/persistence'
41
- require 'active_record/reflection'
42
- require 'active_record/relation'
43
- require 'active_record/sanitization'
44
- require 'active_record/transactions'
45
-
46
- require 'active_record/associations/association'
47
- require 'active_record/associations/association_scope'
48
- require 'active_record/associations/foreign_association'
49
- require 'active_record/associations/has_many_association'
50
- require 'active_record/associations/has_many_through_association'
51
- require 'active_record/associations/join_dependency'
52
- require 'active_record/associations/preloader/association'
53
- require 'active_record/associations/singular_association'
54
- require 'active_record/associations/collection_association'
55
- require 'active_record/associations/through_association'
56
-
57
- require 'active_record/attribute_methods/primary_key'
58
- require 'active_record/attribute_methods/read'
59
- require 'active_record/attribute_methods/write'
60
- require 'active_record/nested_attributes'
61
-
62
- require 'active_record/connection_adapters/abstract/database_statements'
63
- require 'active_record/connection_adapters/abstract_adapter'
64
- require 'active_record/connection_adapters/postgresql/database_statements'
65
-
66
- require 'active_record/relation/where_clause'
67
- require 'active_record/table_metadata'
68
-
69
- # CPK overrides
70
- require_relative 'composite_primary_keys/active_model/attribute_assignment'
71
- require_relative 'composite_primary_keys/attribute_methods'
72
- require_relative 'composite_primary_keys/autosave_association'
73
- require_relative 'composite_primary_keys/persistence'
74
- require_relative 'composite_primary_keys/base'
75
- require_relative 'composite_primary_keys/core'
76
- require_relative 'composite_primary_keys/composite_arrays'
77
- require_relative 'composite_primary_keys/composite_predicates'
78
- require_relative 'composite_primary_keys/counter_cache'
79
- require_relative 'composite_primary_keys/fixtures'
80
- require_relative 'composite_primary_keys/reflection'
81
- require_relative 'composite_primary_keys/relation'
82
- require_relative 'composite_primary_keys/sanitization'
83
- require_relative 'composite_primary_keys/transactions'
84
- require_relative 'composite_primary_keys/version'
85
-
86
- require_relative 'composite_primary_keys/associations/association'
87
- require_relative 'composite_primary_keys/associations/association_scope'
88
- require_relative 'composite_primary_keys/associations/foreign_association'
89
- require_relative 'composite_primary_keys/associations/has_many_association'
90
- require_relative 'composite_primary_keys/associations/has_many_through_association'
91
- require_relative 'composite_primary_keys/associations/join_association'
92
- require_relative 'composite_primary_keys/associations/preloader/association'
93
- require_relative 'composite_primary_keys/associations/collection_association'
94
- require_relative 'composite_primary_keys/associations/through_association'
95
-
96
- require_relative 'composite_primary_keys/attribute_methods/primary_key'
97
- require_relative 'composite_primary_keys/attribute_methods/read'
98
- require_relative 'composite_primary_keys/attribute_methods/write'
99
- require_relative 'composite_primary_keys/nested_attributes'
100
-
101
- require_relative 'composite_primary_keys/connection_adapters/abstract/database_statements'
102
- require_relative 'composite_primary_keys/connection_adapters/abstract_adapter'
103
- require_relative 'composite_primary_keys/connection_adapters/postgresql/database_statements'
104
- require_relative 'composite_primary_keys/connection_adapters/sqlserver/database_statements'
105
-
106
- require_relative 'composite_primary_keys/relation/batches'
107
- require_relative 'composite_primary_keys/relation/where_clause'
108
- require_relative 'composite_primary_keys/relation/calculations'
109
- require_relative 'composite_primary_keys/relation/finder_methods'
110
- require_relative 'composite_primary_keys/relation/predicate_builder/association_query_value'
111
- require_relative 'composite_primary_keys/relation/query_methods'
112
-
113
- require_relative 'composite_primary_keys/validations/uniqueness'
114
-
115
- require_relative 'composite_primary_keys/composite_relation'
116
-
117
- require_relative 'composite_primary_keys/arel/to_sql'
118
- require_relative 'composite_primary_keys/arel/sqlserver'
119
- require_relative 'composite_primary_keys/table_metadata'
1
+ #--
2
+ # Copyright (c) 2006-2016 Nic Williams and Charlie Savage
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ unless defined?(ActiveRecord)
25
+ require 'rubygems'
26
+ gem 'activerecord', '~>7.0.0', '>= 7.0.1'
27
+ require 'active_record'
28
+ end
29
+
30
+ # ActiveModel files we override
31
+ # _write_attribute
32
+ require 'active_model/attribute_assignment'
33
+
34
+ # ActiveRecord files we override
35
+ require 'active_record/attribute_methods'
36
+ require 'active_record/autosave_association'
37
+ require 'active_record/counter_cache'
38
+ require 'active_record/fixtures'
39
+ require 'active_record/model_schema'
40
+ require 'active_record/persistence'
41
+ require 'active_record/reflection'
42
+ require 'active_record/relation'
43
+ require 'active_record/sanitization'
44
+ require 'active_record/transactions'
45
+
46
+ require 'active_record/associations/association'
47
+ require 'active_record/associations/association_scope'
48
+ require 'active_record/associations/foreign_association'
49
+ require 'active_record/associations/has_many_association'
50
+ require 'active_record/associations/has_many_through_association'
51
+ require 'active_record/associations/join_dependency'
52
+ require 'active_record/associations/preloader/association'
53
+ require 'active_record/associations/singular_association'
54
+ require 'active_record/associations/collection_association'
55
+
56
+ require 'active_record/attribute_methods/primary_key'
57
+ require 'active_record/attribute_methods/read'
58
+ require 'active_record/attribute_methods/write'
59
+ require 'active_record/nested_attributes'
60
+
61
+ require 'active_record/connection_adapters/abstract/database_statements'
62
+ require 'active_record/connection_adapters/abstract_adapter'
63
+ require 'active_record/connection_adapters/postgresql/database_statements'
64
+
65
+ require 'active_record/relation/where_clause'
66
+ require 'active_record/table_metadata'
67
+
68
+ # CPK overrides
69
+ require_relative 'composite_primary_keys/active_model/attribute_assignment'
70
+ require_relative 'composite_primary_keys/attribute_methods'
71
+ require_relative 'composite_primary_keys/autosave_association'
72
+ require_relative 'composite_primary_keys/persistence'
73
+ require_relative 'composite_primary_keys/base'
74
+ require_relative 'composite_primary_keys/core'
75
+ require_relative 'composite_primary_keys/composite_arrays'
76
+ require_relative 'composite_primary_keys/composite_predicates'
77
+ require_relative 'composite_primary_keys/counter_cache'
78
+ require_relative 'composite_primary_keys/fixtures'
79
+ require_relative 'composite_primary_keys/reflection'
80
+ require_relative 'composite_primary_keys/relation'
81
+ require_relative 'composite_primary_keys/sanitization'
82
+ require_relative 'composite_primary_keys/transactions'
83
+ require_relative 'composite_primary_keys/version'
84
+
85
+ require_relative 'composite_primary_keys/associations/association'
86
+ require_relative 'composite_primary_keys/associations/association_scope'
87
+ require_relative 'composite_primary_keys/associations/foreign_association'
88
+ require_relative 'composite_primary_keys/associations/has_many_association'
89
+ require_relative 'composite_primary_keys/associations/has_many_through_association'
90
+ require_relative 'composite_primary_keys/associations/join_association'
91
+ require_relative 'composite_primary_keys/associations/preloader/association'
92
+ require_relative 'composite_primary_keys/associations/collection_association'
93
+
94
+ require_relative 'composite_primary_keys/attribute_methods/primary_key'
95
+ require_relative 'composite_primary_keys/attribute_methods/read'
96
+ require_relative 'composite_primary_keys/attribute_methods/write'
97
+ require_relative 'composite_primary_keys/nested_attributes'
98
+
99
+ require_relative 'composite_primary_keys/connection_adapters/abstract/database_statements'
100
+ require_relative 'composite_primary_keys/connection_adapters/abstract_adapter'
101
+ require_relative 'composite_primary_keys/connection_adapters/postgresql/database_statements'
102
+ require_relative 'composite_primary_keys/connection_adapters/sqlserver/database_statements'
103
+
104
+ require_relative 'composite_primary_keys/relation/batches'
105
+ require_relative 'composite_primary_keys/relation/where_clause'
106
+ require_relative 'composite_primary_keys/relation/calculations'
107
+ require_relative 'composite_primary_keys/relation/finder_methods'
108
+ require_relative 'composite_primary_keys/relation/predicate_builder/association_query_value'
109
+ require_relative 'composite_primary_keys/relation/query_methods'
110
+
111
+ require_relative 'composite_primary_keys/validations/uniqueness'
112
+
113
+ require_relative 'composite_primary_keys/composite_relation'
114
+
115
+ require_relative 'composite_primary_keys/arel/to_sql'
116
+ require_relative 'composite_primary_keys/arel/sqlserver'
117
+ require_relative 'composite_primary_keys/table_metadata'
data/scripts/console.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  #
4
- # if run as script, load the file as library while starting irb
4
+ # if run as script, load the file as library while starting irb
5
5
  #
6
6
  if __FILE__ == $0
7
7
  irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
@@ -12,7 +12,7 @@ end
12
12
  #
13
13
  # check if the given adapter is supported (default: mysql)
14
14
  #
15
- adapters = %w[mysql sqlite oracle oracle_enhanced postgresql ibm_db]
15
+ adapters = %w[mysql sqlite oracle oracle_enhanced postgresql ibm_db trilogy]
16
16
  adapter = ENV['ADAPTER'] || 'mysql'
17
17
  unless adapters.include? adapter
18
18
  puts "Usage: #{__FILE__} <adapter>"
@@ -0,0 +1,23 @@
1
+ namespace :trilogy do
2
+ task :setup do
3
+ require 'bundler'
4
+ Bundler.require(:default, :trilogy)
5
+ end
6
+
7
+ task :create_database => :setup do
8
+ Rake::Task["mysql:create_database"].invoke
9
+ end
10
+
11
+ desc 'Build the MySQL test database'
12
+ task :build_database => [:create_database] do
13
+ Rake::Task["mysql:build_database"].invoke
14
+ end
15
+
16
+ desc 'Drop the MySQL test database'
17
+ task :drop_database => :setup do
18
+ Rake::Task["mysql:drop_database"].invoke
19
+ end
20
+
21
+ desc 'Rebuild the MySQL test database'
22
+ task :rebuild_database => [:drop_database, :build_database]
23
+ end