activerecord-oracle_enhanced-adapter 1.7.11 → 1.8.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +2 -0
  3. data/Gemfile +20 -11
  4. data/History.md +123 -4
  5. data/RUNNING_TESTS.md +79 -55
  6. data/Rakefile +13 -19
  7. data/VERSION +1 -1
  8. data/activerecord-oracle_enhanced-adapter.gemspec +16 -17
  9. data/lib/active_record/connection_adapters/emulation/oracle_adapter.rb +1 -1
  10. data/lib/active_record/connection_adapters/oracle_enhanced/column.rb +7 -59
  11. data/lib/active_record/connection_adapters/oracle_enhanced/column_dumper.rb +6 -50
  12. data/lib/active_record/connection_adapters/oracle_enhanced/connection.rb +11 -11
  13. data/lib/active_record/connection_adapters/oracle_enhanced/context_index.rb +117 -117
  14. data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +30 -23
  15. data/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb +10 -10
  16. data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +48 -70
  17. data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb +1 -4
  18. data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +51 -69
  19. data/lib/active_record/connection_adapters/oracle_enhanced/oci_quoting.rb +4 -4
  20. data/lib/active_record/connection_adapters/oracle_enhanced/procedures.rb +76 -76
  21. data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +13 -42
  22. data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +60 -64
  23. data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +33 -47
  24. data/lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb +146 -159
  25. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +94 -132
  26. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements_ext.rb +3 -3
  27. data/lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb +65 -100
  28. data/lib/active_record/connection_adapters/oracle_enhanced/version.rb +1 -1
  29. data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +250 -487
  30. data/lib/active_record/oracle_enhanced/type/boolean.rb +7 -10
  31. data/lib/active_record/oracle_enhanced/type/integer.rb +3 -4
  32. data/lib/active_record/oracle_enhanced/type/national_character_string.rb +1 -1
  33. data/lib/active_record/oracle_enhanced/type/raw.rb +2 -3
  34. data/lib/active_record/oracle_enhanced/type/string.rb +2 -2
  35. data/lib/active_record/oracle_enhanced/type/text.rb +2 -2
  36. data/lib/activerecord-oracle_enhanced-adapter.rb +2 -2
  37. data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +57 -131
  38. data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +32 -34
  39. data/spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb +40 -42
  40. data/spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb +83 -85
  41. data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +205 -286
  42. data/spec/active_record/connection_adapters/oracle_enhanced_database_tasks_spec.rb +14 -6
  43. data/spec/active_record/connection_adapters/oracle_enhanced_dbms_output_spec.rb +3 -5
  44. data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +42 -49
  45. data/spec/active_record/connection_adapters/oracle_enhanced_emulate_oracle_adapter_spec.rb +1 -3
  46. data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +68 -71
  47. data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +51 -92
  48. data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +221 -327
  49. data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +16 -18
  50. data/spec/spec_helper.rb +59 -57
  51. metadata +10 -10
@@ -1,5 +1,3 @@
1
- require 'spec_helper'
2
-
3
1
  describe "OracleEnhancedAdapter structure dump" do
4
2
  include LoggerSpecHelper
5
3
 
@@ -11,7 +9,7 @@ describe "OracleEnhancedAdapter structure dump" do
11
9
  end
12
10
  describe "structure dump" do
13
11
  before(:each) do
14
- @conn.create_table :test_posts, :force => true do |t|
12
+ @conn.create_table :test_posts, force: true do |t|
15
13
  t.string :title
16
14
  t.string :foo
17
15
  t.integer :foo_id
@@ -94,7 +92,7 @@ describe "OracleEnhancedAdapter structure dump" do
94
92
  it "should not error when no foreign keys are present" do
95
93
  dump = ActiveRecord::Base.connection.structure_dump_fk_constraints
96
94
  expect(dump.split('\n').length).to eq(0)
97
- expect(dump).to eq('')
95
+ expect(dump).to eq("")
98
96
  end
99
97
 
100
98
  it "should dump triggers" do
@@ -107,7 +105,7 @@ describe "OracleEnhancedAdapter structure dump" do
107
105
  SELECT 'bar' INTO :new.FOO FROM DUAL;
108
106
  END;
109
107
  SQL
110
- dump = ActiveRecord::Base.connection.structure_dump_db_stored_code.gsub(/\n|\s+/,' ')
108
+ dump = ActiveRecord::Base.connection.structure_dump_db_stored_code.gsub(/\n|\s+/, " ")
111
109
  expect(dump).to match(/CREATE OR REPLACE TRIGGER TEST_POST_TRIGGER/)
112
110
  end
113
111
 
@@ -115,14 +113,14 @@ describe "OracleEnhancedAdapter structure dump" do
115
113
  @conn.execute <<-SQL
116
114
  create or replace TYPE TEST_TYPE AS TABLE OF VARCHAR2(10);
117
115
  SQL
118
- dump = ActiveRecord::Base.connection.structure_dump_db_stored_code.gsub(/\n|\s+/,' ')
116
+ dump = ActiveRecord::Base.connection.structure_dump_db_stored_code.gsub(/\n|\s+/, " ")
119
117
  expect(dump).to match(/CREATE OR REPLACE TYPE TEST_TYPE/)
120
118
  end
121
119
 
122
120
  it "should dump views" do
123
121
  @conn.execute "create or replace VIEW test_posts_view_z as select * from test_posts"
124
122
  @conn.execute "create or replace VIEW test_posts_view_a as select * from test_posts_view_z"
125
- dump = ActiveRecord::Base.connection.structure_dump_db_stored_code.gsub(/\n|\s+/,' ')
123
+ dump = ActiveRecord::Base.connection.structure_dump_db_stored_code.gsub(/\n|\s+/, " ")
126
124
  expect(dump).to match(/CREATE OR REPLACE FORCE VIEW TEST_POSTS_VIEW_A.*CREATE OR REPLACE FORCE VIEW TEST_POSTS_VIEW_Z/)
127
125
  end
128
126
 
@@ -165,8 +163,8 @@ describe "OracleEnhancedAdapter structure dump" do
165
163
  end
166
164
 
167
165
  it "should dump indexes" do
168
- ActiveRecord::Base.connection.add_index(:test_posts, :foo, :name => :ix_test_posts_foo)
169
- ActiveRecord::Base.connection.add_index(:test_posts, :foo_id, :name => :ix_test_posts_foo_id, :unique => true)
166
+ ActiveRecord::Base.connection.add_index(:test_posts, :foo, name: :ix_test_posts_foo)
167
+ ActiveRecord::Base.connection.add_index(:test_posts, :foo_id, name: :ix_test_posts_foo_id, unique: true)
170
168
 
171
169
  @conn.execute <<-SQL
172
170
  ALTER TABLE test_posts
@@ -180,7 +178,7 @@ describe "OracleEnhancedAdapter structure dump" do
180
178
  end
181
179
 
182
180
  it "should dump multi-value and function value indexes" do
183
- ActiveRecord::Base.connection.add_index(:test_posts, [:foo, :foo_id], :name => :ix_test_posts_foo_foo_id)
181
+ ActiveRecord::Base.connection.add_index(:test_posts, [:foo, :foo_id], name: :ix_test_posts_foo_foo_id)
184
182
 
185
183
  @conn.execute <<-SQL
186
184
  CREATE INDEX "IX_TEST_POSTS_FUNCTION" ON "TEST_POSTS" (TO_CHAR(LENGTH("FOO"))||"FOO")
@@ -207,28 +205,28 @@ describe "OracleEnhancedAdapter structure dump" do
207
205
  comment_sql = %Q(COMMENT ON TABLE "TEST_POSTS" IS 'Test posts with ''some'' "quotes"')
208
206
  @conn.execute comment_sql
209
207
  dump = ActiveRecord::Base.connection.structure_dump
210
- dump.should =~ /#{comment_sql}/
208
+ expect(dump).to match(/#{comment_sql}/)
211
209
  end
212
210
 
213
211
  it "should dump column comments" do
214
212
  comment_sql = %Q(COMMENT ON COLUMN "TEST_POSTS"."TITLE" IS 'The title of the post with ''some'' "quotes"')
215
213
  @conn.execute comment_sql
216
214
  dump = ActiveRecord::Base.connection.structure_dump
217
- dump.should =~ /#{comment_sql}/
215
+ expect(dump).to match(/#{comment_sql}/)
218
216
  end
219
217
 
220
218
  it "should dump table comments" do
221
219
  comment_sql = %Q(COMMENT ON TABLE "TEST_POSTS" IS 'Test posts with ''some'' "quotes"')
222
220
  @conn.execute comment_sql
223
221
  dump = ActiveRecord::Base.connection.structure_dump
224
- dump.should =~ /#{comment_sql}/
222
+ expect(dump).to match(/#{comment_sql}/)
225
223
  end
226
224
 
227
225
  it "should dump column comments" do
228
226
  comment_sql = %Q(COMMENT ON COLUMN "TEST_POSTS"."TITLE" IS 'The title of the post with ''some'' "quotes"')
229
227
  @conn.execute comment_sql
230
228
  dump = ActiveRecord::Base.connection.structure_dump
231
- dump.should =~ /#{comment_sql}/
229
+ expect(dump).to match(/#{comment_sql}/)
232
230
  end
233
231
 
234
232
  end
@@ -237,7 +235,7 @@ describe "OracleEnhancedAdapter structure dump" do
237
235
  @conn.drop_table :test_comments rescue nil
238
236
  end
239
237
  it "should dump correctly" do
240
- @conn.create_table :test_comments, :temporary => true, :id => false do |t|
238
+ @conn.create_table :test_comments, temporary: true, id: false do |t|
241
239
  t.integer :post_id
242
240
  end
243
241
  dump = ActiveRecord::Base.connection.structure_dump
@@ -267,7 +265,7 @@ describe "OracleEnhancedAdapter structure dump" do
267
265
 
268
266
  describe "temp_table_drop" do
269
267
  before(:each) do
270
- @conn.create_table :temp_tbl, :temporary => true do |t|
268
+ @conn.create_table :temp_tbl, temporary: true do |t|
271
269
  t.string :foo
272
270
  end
273
271
  @conn.create_table :not_temp_tbl do |t|
@@ -298,7 +296,7 @@ describe "OracleEnhancedAdapter structure dump" do
298
296
  ActiveRecord::SchemaMigration.reset_table_name
299
297
  ActiveRecord::SchemaMigration.create_table
300
298
  versions.each do |i|
301
- ActiveRecord::SchemaMigration.create!(:version => i)
299
+ ActiveRecord::SchemaMigration.create!(version: i)
302
300
  end
303
301
  end
304
302
 
@@ -347,7 +345,7 @@ describe "OracleEnhancedAdapter structure dump" do
347
345
  @conn.create_table :full_drop_test do |t|
348
346
  t.string :foo
349
347
  end
350
- @conn.create_table :full_drop_test_temp, :temporary => true do |t|
348
+ @conn.create_table :full_drop_test_temp, temporary: true do |t|
351
349
  t.string :foo
352
350
  end
353
351
  #view
data/spec/spec_helper.rb CHANGED
@@ -1,41 +1,43 @@
1
+ require "simplecov"
2
+ SimpleCov.start
1
3
  require "rubygems"
2
4
  require "bundler"
3
5
  require "yaml"
4
6
  Bundler.setup(:default, :development)
5
7
 
6
- $:.unshift(File.expand_path('../../lib', __FILE__))
7
- config_path = File.expand_path('../spec_config.yaml', __FILE__)
8
+ $:.unshift(File.expand_path("../../lib", __FILE__))
9
+ config_path = File.expand_path("../spec_config.yaml", __FILE__)
8
10
  if File.exist?(config_path)
9
11
  puts "==> Loading config from #{config_path}"
10
12
  config = YAML.load_file(config_path)
11
13
  else
12
14
  puts "==> Loading config from ENV or use default"
13
- config = {"rails" => {}, "database" => {}}
15
+ config = { "rails" => {}, "database" => {} }
14
16
  end
15
17
 
16
- require 'rspec'
18
+ require "rspec"
17
19
 
18
- if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby'
20
+ if !defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby"
19
21
  puts "==> Running specs with MRI version #{RUBY_VERSION}"
20
- require 'oci8'
21
- elsif RUBY_ENGINE == 'jruby'
22
+ require "oci8"
23
+ elsif RUBY_ENGINE == "jruby"
22
24
  puts "==> Running specs with JRuby version #{JRUBY_VERSION}"
23
25
  end
24
26
 
25
27
  NO_COMPOSITE_PRIMARY_KEYS = true
26
28
 
27
- require 'active_record'
29
+ require "active_record"
28
30
 
29
- require 'active_support/core_ext/module/attribute_accessors'
30
- require 'active_support/core_ext/class/attribute_accessors'
31
+ require "active_support/core_ext/module/attribute_accessors"
32
+ require "active_support/core_ext/class/attribute_accessors"
31
33
 
32
34
  require "active_support/log_subscriber"
33
- require 'active_record/log_subscriber'
35
+ require "active_record/log_subscriber"
34
36
 
35
- require 'logger'
37
+ require "logger"
36
38
 
37
- require 'active_record/connection_adapters/oracle_enhanced_adapter'
38
- require 'ruby-plsql'
39
+ require "active_record/connection_adapters/oracle_enhanced_adapter"
40
+ require "ruby-plsql"
39
41
 
40
42
  puts "==> Effective ActiveRecord version #{ActiveRecord::VERSION::STRING}"
41
43
 
@@ -61,7 +63,7 @@ module LoggerSpecHelper
61
63
 
62
64
  def initialize
63
65
  @flush_count = 0
64
- @logged = Hash.new { |h,k| h[k] = [] }
66
+ @logged = Hash.new { |h, k| h[k] = [] }
65
67
  end
66
68
 
67
69
  # used in AtiveRecord 2.x
@@ -115,66 +117,66 @@ module SchemaSpecHelper
115
117
  end
116
118
  end
117
119
 
118
- DATABASE_NAME = config["database"]["name"] || ENV['DATABASE_NAME'] || 'orcl'
119
- DATABASE_HOST = config["database"]["host"] || ENV['DATABASE_HOST'] || "127.0.0.1"
120
- DATABASE_PORT = config["database"]["port"] || ENV['DATABASE_PORT'] || 1521
121
- DATABASE_USER = config["database"]["user"] || ENV['DATABASE_USER'] || 'oracle_enhanced'
122
- DATABASE_PASSWORD = config["database"]["password"] || ENV['DATABASE_PASSWORD'] || 'oracle_enhanced'
123
- DATABASE_SCHEMA = config["database"]["schema"] || ENV['DATABASE_SCHEMA'] || 'oracle_enhanced_schema'
124
- DATABASE_SYS_PASSWORD = config["database"]["sys_password"] || ENV['DATABASE_SYS_PASSWORD'] || 'admin'
120
+ DATABASE_NAME = config["database"]["name"] || ENV["DATABASE_NAME"] || "orcl"
121
+ DATABASE_HOST = config["database"]["host"] || ENV["DATABASE_HOST"] || "127.0.0.1"
122
+ DATABASE_PORT = config["database"]["port"] || ENV["DATABASE_PORT"] || 1521
123
+ DATABASE_USER = config["database"]["user"] || ENV["DATABASE_USER"] || "oracle_enhanced"
124
+ DATABASE_PASSWORD = config["database"]["password"] || ENV["DATABASE_PASSWORD"] || "oracle_enhanced"
125
+ DATABASE_SCHEMA = config["database"]["schema"] || ENV["DATABASE_SCHEMA"] || "oracle_enhanced_schema"
126
+ DATABASE_SYS_PASSWORD = config["database"]["sys_password"] || ENV["DATABASE_SYS_PASSWORD"] || "admin"
125
127
 
126
128
  CONNECTION_PARAMS = {
127
- :adapter => "oracle_enhanced",
128
- :database => DATABASE_NAME,
129
- :host => DATABASE_HOST,
130
- :port => DATABASE_PORT,
131
- :username => DATABASE_USER,
132
- :password => DATABASE_PASSWORD
129
+ adapter: "oracle_enhanced",
130
+ database: DATABASE_NAME,
131
+ host: DATABASE_HOST,
132
+ port: DATABASE_PORT,
133
+ username: DATABASE_USER,
134
+ password: DATABASE_PASSWORD
133
135
  }
134
136
 
135
137
  CONNECTION_WITH_SCHEMA_PARAMS = {
136
- :adapter => "oracle_enhanced",
137
- :database => DATABASE_NAME,
138
- :host => DATABASE_HOST,
139
- :port => DATABASE_PORT,
140
- :username => DATABASE_USER,
141
- :password => DATABASE_PASSWORD,
142
- :schema => DATABASE_SCHEMA
138
+ adapter: "oracle_enhanced",
139
+ database: DATABASE_NAME,
140
+ host: DATABASE_HOST,
141
+ port: DATABASE_PORT,
142
+ username: DATABASE_USER,
143
+ password: DATABASE_PASSWORD,
144
+ schema: DATABASE_SCHEMA
143
145
  }
144
146
 
145
147
  CONNECTION_WITH_TIMEZONE_PARAMS = {
146
- :adapter => "oracle_enhanced",
147
- :database => DATABASE_NAME,
148
- :host => DATABASE_HOST,
149
- :port => DATABASE_PORT,
150
- :username => DATABASE_USER,
151
- :password => DATABASE_PASSWORD,
152
- :time_zone => "Europe/Riga"
148
+ adapter: "oracle_enhanced",
149
+ database: DATABASE_NAME,
150
+ host: DATABASE_HOST,
151
+ port: DATABASE_PORT,
152
+ username: DATABASE_USER,
153
+ password: DATABASE_PASSWORD,
154
+ time_zone: "Europe/Riga"
153
155
  }
154
156
 
155
157
  SYS_CONNECTION_PARAMS = {
156
- :adapter => "oracle_enhanced",
157
- :database => DATABASE_NAME,
158
- :host => DATABASE_HOST,
159
- :port => DATABASE_PORT,
160
- :username => "sys",
161
- :password => DATABASE_SYS_PASSWORD,
162
- :privilege => "SYSDBA"
158
+ adapter: "oracle_enhanced",
159
+ database: DATABASE_NAME,
160
+ host: DATABASE_HOST,
161
+ port: DATABASE_PORT,
162
+ username: "sys",
163
+ password: DATABASE_SYS_PASSWORD,
164
+ privilege: "SYSDBA"
163
165
  }
164
166
 
165
167
  SYSTEM_CONNECTION_PARAMS = {
166
- :adapter => "oracle_enhanced",
167
- :database => DATABASE_NAME,
168
- :host => DATABASE_HOST,
169
- :port => DATABASE_PORT,
170
- :username => "system",
171
- :password => DATABASE_SYS_PASSWORD
168
+ adapter: "oracle_enhanced",
169
+ database: DATABASE_NAME,
170
+ host: DATABASE_HOST,
171
+ port: DATABASE_PORT,
172
+ username: "system",
173
+ password: DATABASE_SYS_PASSWORD
172
174
  }
173
175
 
174
- DATABASE_NON_DEFAULT_TABLESPACE = config["database"]["non_default_tablespace"] || ENV['DATABASE_NON_DEFAULT_TABLESPACE'] || "SYSTEM"
176
+ DATABASE_NON_DEFAULT_TABLESPACE = config["database"]["non_default_tablespace"] || ENV["DATABASE_NON_DEFAULT_TABLESPACE"] || "SYSTEM"
175
177
 
176
178
  # set default time zone in TZ environment variable
177
179
  # which will be used to set session time zone
178
- ENV['TZ'] ||= config["timezone"] || 'Europe/Riga'
180
+ ENV["TZ"] ||= config["timezone"] || "Europe/Riga"
179
181
 
180
182
  # ActiveRecord::Base.logger = Logger.new(STDOUT)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activerecord-oracle_enhanced-adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.11
4
+ version: 1.8.0.beta1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Raimonds Simanovskis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-29 00:00:00.000000000 Z
11
+ date: 2016-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 5.0.0
19
+ version: 5.1.0.beta
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 5.0.0
26
+ version: 5.1.0.beta
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: arel
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 7.1.4
33
+ version: '8.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 7.1.4
40
+ version: '8.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: ruby-plsql
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 0.5.0
47
+ version: '0'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 0.5.0
54
+ version: '0'
55
55
  description: |
56
56
  Oracle "enhanced" ActiveRecord adapter contains useful additional methods for working with new and legacy Oracle databases.
57
57
  This adapter is superset of original ActiveRecord Oracle adapter.
@@ -130,10 +130,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  requirements:
131
131
  - - ">="
132
132
  - !ruby/object:Gem::Version
133
- version: '0'
133
+ version: 1.8.11
134
134
  requirements: []
135
135
  rubyforge_project:
136
- rubygems_version: 2.6.11
136
+ rubygems_version: 2.6.10
137
137
  signing_key:
138
138
  specification_version: 4
139
139
  summary: Oracle enhanced adapter for ActiveRecord