activerecord-oracle_enhanced-adapter 5.2.8 → 6.0.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/History.md +79 -13
- data/README.md +1 -7
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/connection.rb +10 -13
- data/lib/active_record/connection_adapters/oracle_enhanced/context_index.rb +7 -7
- data/lib/active_record/connection_adapters/oracle_enhanced/database_limits.rb +4 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +7 -18
- data/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +17 -4
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +32 -32
- data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +17 -27
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +4 -4
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +13 -3
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb +1 -13
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +55 -71
- data/lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb +27 -17
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +87 -61
- data/lib/active_record/type/oracle_enhanced/character_string.rb +36 -0
- data/spec/active_record/connection_adapters/emulation/oracle_adapter_spec.rb +0 -2
- data/spec/active_record/connection_adapters/oracle_enhanced/connection_spec.rb +25 -50
- data/spec/active_record/connection_adapters/oracle_enhanced/context_index_spec.rb +5 -13
- data/spec/active_record/connection_adapters/oracle_enhanced/procedures_spec.rb +0 -2
- data/spec/active_record/connection_adapters/oracle_enhanced/quoting_spec.rb +0 -15
- data/spec/active_record/connection_adapters/oracle_enhanced/schema_dumper_spec.rb +1 -31
- data/spec/active_record/connection_adapters/oracle_enhanced/schema_statements_spec.rb +71 -253
- data/spec/active_record/connection_adapters/oracle_enhanced/structure_dump_spec.rb +2 -3
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +81 -81
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +0 -1
- data/spec/active_record/oracle_enhanced/type/boolean_spec.rb +0 -2
- data/spec/active_record/oracle_enhanced/type/character_string_spec.rb +43 -0
- data/spec/active_record/oracle_enhanced/type/decimal_spec.rb +56 -0
- data/spec/active_record/oracle_enhanced/type/dirty_spec.rb +1 -1
- data/spec/active_record/oracle_enhanced/type/json_spec.rb +0 -1
- data/spec/active_record/oracle_enhanced/type/national_character_string_spec.rb +1 -2
- data/spec/active_record/oracle_enhanced/type/timestamp_spec.rb +0 -2
- data/spec/spec_helper.rb +2 -0
- metadata +27 -23
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements_ext.rb +0 -28
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_model/type/string"
|
4
|
+
|
5
|
+
module ActiveRecord
|
6
|
+
module Type
|
7
|
+
module OracleEnhanced
|
8
|
+
class CharacterString < ActiveRecord::Type::OracleEnhanced::String # :nodoc:
|
9
|
+
def serialize(value)
|
10
|
+
return unless value
|
11
|
+
Data.new(super, self.limit)
|
12
|
+
end
|
13
|
+
|
14
|
+
class Data # :nodoc:
|
15
|
+
def initialize(value, limit)
|
16
|
+
@value = value
|
17
|
+
@limit = limit
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
@value
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_character_str
|
25
|
+
len = @value.to_s.length
|
26
|
+
if len < @limit
|
27
|
+
"%-#{@limit}s" % @value
|
28
|
+
else
|
29
|
+
@value
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe "OracleEnhancedAdapter emulate OracleAdapter" do
|
4
|
-
|
5
4
|
before(:all) do
|
6
5
|
@old_oracle_adapter = nil
|
7
6
|
if defined?(ActiveRecord::ConnectionAdapters::OracleAdapter)
|
@@ -22,5 +21,4 @@ describe "OracleEnhancedAdapter emulate OracleAdapter" do
|
|
22
21
|
ActiveRecord::ConnectionAdapters::OracleAdapter = @old_oracle_adapter
|
23
22
|
end
|
24
23
|
end
|
25
|
-
|
26
24
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
describe "OracleEnhancedAdapter establish connection" do
|
4
|
-
|
5
4
|
it "should connect to database" do
|
6
5
|
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
7
6
|
expect(ActiveRecord::Base.connection).not_to be_nil
|
@@ -44,7 +43,6 @@ describe "OracleEnhancedAdapter establish connection" do
|
|
44
43
|
end
|
45
44
|
|
46
45
|
describe "OracleEnhancedConnection" do
|
47
|
-
|
48
46
|
describe "create connection" do
|
49
47
|
before(:all) do
|
50
48
|
@conn = ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection.create(CONNECTION_PARAMS)
|
@@ -75,11 +73,9 @@ describe "OracleEnhancedConnection" do
|
|
75
73
|
it "should be in autocommit mode after connection" do
|
76
74
|
expect(@conn).to be_autocommit
|
77
75
|
end
|
78
|
-
|
79
76
|
end
|
80
77
|
|
81
78
|
describe "create connection with schema option" do
|
82
|
-
|
83
79
|
it "should create new connection" do
|
84
80
|
ActiveRecord::Base.establish_connection(CONNECTION_WITH_SCHEMA_PARAMS)
|
85
81
|
expect(ActiveRecord::Base.connection).to be_active
|
@@ -88,68 +84,57 @@ describe "OracleEnhancedConnection" do
|
|
88
84
|
it "should swith to specified schema" do
|
89
85
|
ActiveRecord::Base.establish_connection(CONNECTION_WITH_SCHEMA_PARAMS)
|
90
86
|
expect(ActiveRecord::Base.connection.current_schema).to eq(CONNECTION_WITH_SCHEMA_PARAMS[:schema].upcase)
|
87
|
+
expect(ActiveRecord::Base.connection.current_user).to eq(CONNECTION_WITH_SCHEMA_PARAMS[:username].upcase)
|
91
88
|
end
|
92
89
|
|
93
90
|
it "should swith to specified schema after reset" do
|
94
91
|
ActiveRecord::Base.connection.reset!
|
95
92
|
expect(ActiveRecord::Base.connection.current_schema).to eq(CONNECTION_WITH_SCHEMA_PARAMS[:schema].upcase)
|
96
93
|
end
|
97
|
-
|
98
94
|
end
|
99
95
|
|
100
96
|
describe "create connection with NLS parameters" do
|
97
|
+
after do
|
98
|
+
ENV["NLS_TERRITORY"] = nil
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should use NLS_TERRITORY environment variable" do
|
102
|
+
ENV["NLS_TERRITORY"] = "JAPAN"
|
103
|
+
@conn = ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection.create(CONNECTION_PARAMS)
|
104
|
+
expect(@conn.select("select SYS_CONTEXT('userenv', 'NLS_TERRITORY') as value from dual")).to eq([{ "value" => "JAPAN" }])
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should use configuration value and ignore NLS_TERRITORY environment variable" do
|
108
|
+
ENV["NLS_TERRITORY"] = "AMERICA"
|
109
|
+
@conn = ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection.create(CONNECTION_PARAMS.merge(nls_territory: "INDONESIA"))
|
110
|
+
expect(@conn.select("select SYS_CONTEXT('userenv', 'NLS_TERRITORY') as value from dual")).to eq([{ "value" => "INDONESIA" }])
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe "Fixed NLS parameters" do
|
101
115
|
after do
|
102
116
|
ENV["NLS_DATE_FORMAT"] = nil
|
103
117
|
end
|
104
118
|
|
105
|
-
it "should
|
119
|
+
it "should ignore NLS_DATE_FORMAT environment variable" do
|
106
120
|
ENV["NLS_DATE_FORMAT"] = "YYYY-MM-DD"
|
107
121
|
@conn = ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection.create(CONNECTION_PARAMS)
|
108
|
-
expect(@conn.select("select SYS_CONTEXT('userenv', 'NLS_DATE_FORMAT') as value from dual")).to eq([{ "value" => "YYYY-MM-DD" }])
|
122
|
+
expect(@conn.select("select SYS_CONTEXT('userenv', 'NLS_DATE_FORMAT') as value from dual")).to eq([{ "value" => "YYYY-MM-DD HH24:MI:SS" }])
|
109
123
|
end
|
110
124
|
|
111
|
-
it "should
|
112
|
-
ENV["NLS_DATE_FORMAT"] = "YYYY-MM-DD"
|
125
|
+
it "should ignore NLS_DATE_FORMAT configuration value" do
|
113
126
|
@conn = ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection.create(CONNECTION_PARAMS.merge(nls_date_format: "YYYY-MM-DD HH24:MI"))
|
114
|
-
expect(@conn.select("select SYS_CONTEXT('userenv', 'NLS_DATE_FORMAT') as value from dual")).to eq([{ "value" => "YYYY-MM-DD HH24:MI" }])
|
127
|
+
expect(@conn.select("select SYS_CONTEXT('userenv', 'NLS_DATE_FORMAT') as value from dual")).to eq([{ "value" => "YYYY-MM-DD HH24:MI:SS" }])
|
115
128
|
end
|
116
129
|
|
117
130
|
it "should use default value when NLS_DATE_FORMAT environment variable is not set" do
|
118
131
|
ENV["NLS_DATE_FORMAT"] = nil
|
119
132
|
@conn = ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection.create(CONNECTION_PARAMS)
|
120
|
-
default = ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter::
|
133
|
+
default = ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter::FIXED_NLS_PARAMETERS[:nls_date_format]
|
121
134
|
expect(@conn.select("select SYS_CONTEXT('userenv', 'NLS_DATE_FORMAT') as value from dual")).to eq([{ "value" => default }])
|
122
135
|
end
|
123
136
|
end
|
124
137
|
|
125
|
-
if defined?(OCI8)
|
126
|
-
describe "with TCP keepalive parameters" do
|
127
|
-
it "should use database default `tcp_keepalive` value true by default" do
|
128
|
-
ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection.create(CONNECTION_PARAMS)
|
129
|
-
|
130
|
-
expect(OCI8.properties[:tcp_keepalive]).to be true
|
131
|
-
end
|
132
|
-
|
133
|
-
it "should use modified `tcp_keepalive` value false" do
|
134
|
-
ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection.create(CONNECTION_PARAMS.dup.merge(tcp_keepalive: false))
|
135
|
-
|
136
|
-
expect(OCI8.properties[:tcp_keepalive]).to be false
|
137
|
-
end
|
138
|
-
|
139
|
-
it "should use database default `tcp_keepalive_time` value 600 by default" do
|
140
|
-
ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection.create(CONNECTION_PARAMS)
|
141
|
-
|
142
|
-
expect(OCI8.properties[:tcp_keepalive_time]).to eq(600)
|
143
|
-
end
|
144
|
-
|
145
|
-
it "should use modified `tcp_keepalive_time` value 3000" do
|
146
|
-
ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection.create(CONNECTION_PARAMS.dup.merge(tcp_keepalive_time: 3000))
|
147
|
-
|
148
|
-
expect(OCI8.properties[:tcp_keepalive_time]).to eq(3000)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
138
|
describe "with non-string parameters" do
|
154
139
|
before(:all) do
|
155
140
|
params = CONNECTION_PARAMS.dup
|
@@ -202,7 +187,6 @@ describe "OracleEnhancedConnection" do
|
|
202
187
|
created_at = post.created_at
|
203
188
|
expect(post).to eq(Post.find_by!(created_at: created_at))
|
204
189
|
end
|
205
|
-
|
206
190
|
end
|
207
191
|
|
208
192
|
describe 'with host="connection-string"' do
|
@@ -225,7 +209,6 @@ describe "OracleEnhancedConnection" do
|
|
225
209
|
if defined?(RUBY_ENGINE) && RUBY_ENGINE == "jruby"
|
226
210
|
|
227
211
|
describe "create JDBC connection" do
|
228
|
-
|
229
212
|
it "should create new connection using :url" do
|
230
213
|
params = CONNECTION_PARAMS.dup
|
231
214
|
params[:url] = "jdbc:oracle:thin:@#{DATABASE_HOST && "//#{DATABASE_HOST}#{DATABASE_PORT && ":#{DATABASE_PORT}"}/"}#{DATABASE_NAME}"
|
@@ -253,7 +236,6 @@ describe "OracleEnhancedConnection" do
|
|
253
236
|
end
|
254
237
|
|
255
238
|
it "should create a new connection using JNDI" do
|
256
|
-
|
257
239
|
begin
|
258
240
|
import "oracle.jdbc.driver.OracleDriver"
|
259
241
|
import "org.apache.commons.pool.impl.GenericObjectPool"
|
@@ -274,7 +256,7 @@ describe "OracleEnhancedConnection" do
|
|
274
256
|
@data_source.access_to_underlying_connection_allowed = true
|
275
257
|
end
|
276
258
|
def lookup(path)
|
277
|
-
if
|
259
|
+
if path == "java:/comp/env"
|
278
260
|
self
|
279
261
|
else
|
280
262
|
@data_source
|
@@ -289,7 +271,6 @@ describe "OracleEnhancedConnection" do
|
|
289
271
|
@conn = ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection.create(params)
|
290
272
|
expect(@conn).to be_active
|
291
273
|
end
|
292
|
-
|
293
274
|
end
|
294
275
|
|
295
276
|
it "should fall back to directly instantiating OracleDriver" do
|
@@ -320,7 +301,6 @@ describe "OracleEnhancedConnection" do
|
|
320
301
|
it "should execute SQL select and return also columns" do
|
321
302
|
expect(@conn.select("SELECT * FROM dual", nil, true)).to eq([ [{ "dummy" => "X" }], ["dummy"] ])
|
322
303
|
end
|
323
|
-
|
324
304
|
end
|
325
305
|
|
326
306
|
describe "SQL with bind parameters" do
|
@@ -432,7 +412,6 @@ describe "OracleEnhancedConnection" do
|
|
432
412
|
expect { @conn.select("SELECT * FROM dual") }.to raise_error(OCIError)
|
433
413
|
end
|
434
414
|
end
|
435
|
-
|
436
415
|
end
|
437
416
|
|
438
417
|
describe "describe table" do
|
@@ -483,15 +462,11 @@ describe "OracleEnhancedConnection" do
|
|
483
462
|
|
484
463
|
if defined?(OCI8)
|
485
464
|
context "OCI8 adapter" do
|
486
|
-
|
487
465
|
it "should not fallback to SELECT-based logic when querying non-existent table information" do
|
488
466
|
expect(@conn).not_to receive(:select_one)
|
489
467
|
@conn.describe("non_existent") rescue ActiveRecord::ConnectionAdapters::OracleEnhanced::ConnectionException
|
490
468
|
end
|
491
|
-
|
492
469
|
end
|
493
470
|
end
|
494
|
-
|
495
471
|
end
|
496
|
-
|
497
472
|
end
|
@@ -131,10 +131,10 @@ describe "OracleEnhancedAdapter context index" do
|
|
131
131
|
@post = Post.create(title: "abc", body: "def")
|
132
132
|
expect(Post.contains(:all_text, "abc").to_a).to eq([@post])
|
133
133
|
expect(Post.contains(:all_text, "def").to_a).to eq([@post])
|
134
|
-
@post.
|
134
|
+
@post.update!(title: "ghi")
|
135
135
|
# index will not be updated as all_text column is not changed
|
136
136
|
expect(Post.contains(:all_text, "ghi").to_a).to be_empty
|
137
|
-
@post.
|
137
|
+
@post.update!(all_text: "1")
|
138
138
|
# index will be updated when all_text column is changed
|
139
139
|
expect(Post.contains(:all_text, "ghi").to_a).to eq([@post])
|
140
140
|
@conn.remove_context_index :posts, index_column: :all_text
|
@@ -147,7 +147,7 @@ describe "OracleEnhancedAdapter context index" do
|
|
147
147
|
@post = Post.create(title: "abc", body: "def")
|
148
148
|
expect(Post.contains(:all_text, "abc").to_a).to eq([@post])
|
149
149
|
expect(Post.contains(:all_text, "def").to_a).to eq([@post])
|
150
|
-
@post.
|
150
|
+
@post.update!(title: "ghi")
|
151
151
|
# index should be updated as created_at column is changed
|
152
152
|
expect(Post.contains(:all_text, "ghi").to_a).to eq([@post])
|
153
153
|
@conn.remove_context_index :posts, index_column: :all_text
|
@@ -168,7 +168,7 @@ describe "OracleEnhancedAdapter context index" do
|
|
168
168
|
Post.transaction do
|
169
169
|
@post = Post.create(title: "abc")
|
170
170
|
expect(Post.contains(:title, "abc").to_a).to eq([@post])
|
171
|
-
@post.
|
171
|
+
@post.update!(title: "ghi")
|
172
172
|
expect(Post.contains(:title, "ghi").to_a).to eq([@post])
|
173
173
|
end
|
174
174
|
@conn.remove_context_index :posts, :title
|
@@ -265,7 +265,6 @@ describe "OracleEnhancedAdapter context index" do
|
|
265
265
|
expect(Post.contains(:all_text, "ddd within comment_body").to_a).to eq([@post])
|
266
266
|
expect(Post.contains(:all_text, "ddd within comment_author").to_a).to be_empty
|
267
267
|
end
|
268
|
-
|
269
268
|
end
|
270
269
|
|
271
270
|
describe "with specified tablespace" do
|
@@ -311,13 +310,10 @@ describe "OracleEnhancedAdapter context index" do
|
|
311
310
|
expect(Post.contains(:title, "aaa AND bbb").to_a).to eq([@post])
|
312
311
|
@conn.remove_context_index :posts, name: "index_posts_text"
|
313
312
|
end
|
314
|
-
|
315
313
|
end
|
316
314
|
|
317
315
|
describe "schema dump" do
|
318
|
-
|
319
316
|
describe "without table prefixe and suffix" do
|
320
|
-
|
321
317
|
before(:all) do
|
322
318
|
@conn = ActiveRecord::Base.connection
|
323
319
|
create_tables
|
@@ -382,7 +378,6 @@ describe "OracleEnhancedAdapter context index" do
|
|
382
378
|
expect(output).to match(/add_context_index "posts", \[:title, :body, "#{sub_query.gsub(/\n/, ' ')}"\], #{options.inspect[1..-2]}$/)
|
383
379
|
@conn.remove_context_index :posts, name: "post_and_comments_index"
|
384
380
|
end
|
385
|
-
|
386
381
|
end
|
387
382
|
|
388
383
|
describe "with table prefix and suffix" do
|
@@ -428,12 +423,9 @@ describe "OracleEnhancedAdapter context index" do
|
|
428
423
|
end
|
429
424
|
output = dump_table_schema "posts"
|
430
425
|
expect(output).to match(/add_context_index "posts", \[:title, :body, "SELECT comments.author AS comment_author, comments.body AS comment_body FROM comments WHERE comments.post_id = :id"\], #{
|
431
|
-
options.inspect[1..-2].gsub(/[{}]/) { |s| '\\'
|
426
|
+
options.inspect[1..-2].gsub(/[{}]/) { |s| +'\\' << s }}$/)
|
432
427
|
schema_define { remove_context_index :posts, name: "xxx_post_and_comments_i" }
|
433
428
|
end
|
434
|
-
|
435
429
|
end
|
436
|
-
|
437
430
|
end
|
438
|
-
|
439
431
|
end
|
@@ -87,7 +87,6 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
87
87
|
END delete_employee;
|
88
88
|
END;
|
89
89
|
SQL
|
90
|
-
|
91
90
|
end
|
92
91
|
|
93
92
|
after(:all) do
|
@@ -361,5 +360,4 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
361
360
|
expect(@employee.save).to be_falsey
|
362
361
|
expect(@employee.errors[:first_name]).not_to be_blank
|
363
362
|
end
|
364
|
-
|
365
363
|
end
|
@@ -9,7 +9,6 @@ describe "OracleEnhancedAdapter quoting" do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "reserved words column quoting" do
|
12
|
-
|
13
12
|
before(:all) do
|
14
13
|
schema_define do
|
15
14
|
create_table :test_reserved_words do |t|
|
@@ -60,7 +59,6 @@ describe "OracleEnhancedAdapter quoting" do
|
|
60
59
|
it "should remove double quotes in column quoting" do
|
61
60
|
expect(ActiveRecord::Base.connection.quote_column_name('aaa "bbb" ccc')).to eq('"aaa bbb ccc"')
|
62
61
|
end
|
63
|
-
|
64
62
|
end
|
65
63
|
|
66
64
|
describe "valid table names" do
|
@@ -88,10 +86,6 @@ describe "OracleEnhancedAdapter quoting" do
|
|
88
86
|
expect(@adapter.valid_table_name?("ABC_123.DEF_456")).to be_truthy
|
89
87
|
end
|
90
88
|
|
91
|
-
it "should be valid with irregular schema name and database links" do
|
92
|
-
expect(@adapter.valid_table_name?('abc$#_123.abc$#_123@abc$#@._123')).to be_truthy
|
93
|
-
end
|
94
|
-
|
95
89
|
it "should not be valid with two dots in name" do
|
96
90
|
expect(@adapter.valid_table_name?("abc_123.def_456.ghi_789")).to be_falsey
|
97
91
|
end
|
@@ -114,10 +108,6 @@ describe "OracleEnhancedAdapter quoting" do
|
|
114
108
|
expect(@adapter.valid_table_name?(("a" * 31) + ".validname")).to be_falsey
|
115
109
|
end
|
116
110
|
|
117
|
-
it "should not be valid for database links > 128 characters" do
|
118
|
-
expect(@adapter.valid_table_name?("name@" + "a" * 129)).to be_falsey
|
119
|
-
end
|
120
|
-
|
121
111
|
it "should not be valid for names that do not begin with alphabetic characters" do
|
122
112
|
expect(@adapter.valid_table_name?("1abc")).to be_falsey
|
123
113
|
expect(@adapter.valid_table_name?("_abc")).to be_falsey
|
@@ -127,7 +117,6 @@ describe "OracleEnhancedAdapter quoting" do
|
|
127
117
|
end
|
128
118
|
|
129
119
|
describe "table quoting" do
|
130
|
-
|
131
120
|
def create_warehouse_things_table
|
132
121
|
ActiveRecord::Schema.define do
|
133
122
|
suppress_messages do
|
@@ -188,9 +177,5 @@ describe "OracleEnhancedAdapter quoting" do
|
|
188
177
|
|
189
178
|
expect(@conn.tables).to include("CamelCase")
|
190
179
|
end
|
191
|
-
|
192
|
-
it "properly quotes database links" do
|
193
|
-
expect(@conn.quote_table_name("asdf@some.link")).to eq('"ASDF"@"SOME.LINK"')
|
194
|
-
end
|
195
180
|
end
|
196
181
|
end
|
@@ -19,7 +19,7 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def create_test_posts_table(options = {})
|
22
|
-
options
|
22
|
+
options[:force] = true
|
23
23
|
schema_define do
|
24
24
|
create_table :test_posts, options do |t|
|
25
25
|
t.string :title
|
@@ -51,7 +51,6 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
51
51
|
create_test_posts_table
|
52
52
|
expect(standard_dump(ignore_tables: [ /test_posts/i ])).not_to match(/create_table "test_posts"/)
|
53
53
|
end
|
54
|
-
|
55
54
|
end
|
56
55
|
|
57
56
|
describe "dumping default values" do
|
@@ -86,7 +85,6 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
86
85
|
output = dump_table_schema "test_posts"
|
87
86
|
expect(output).to match(/create_table "test_posts", primary_key: "post_id"/)
|
88
87
|
end
|
89
|
-
|
90
88
|
end
|
91
89
|
|
92
90
|
describe "table with ntext columns" do
|
@@ -110,24 +108,6 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
110
108
|
end
|
111
109
|
end
|
112
110
|
|
113
|
-
describe "table with primary key trigger" do
|
114
|
-
|
115
|
-
after(:each) do
|
116
|
-
drop_test_posts_table
|
117
|
-
end
|
118
|
-
|
119
|
-
it "should include primary key trigger in schema dump" do
|
120
|
-
create_test_posts_table(primary_key_trigger: true)
|
121
|
-
expect(standard_dump).to match(/create_table "test_posts".*add_primary_key_trigger "test_posts"/m)
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should include primary key trigger with non-default primary key in schema dump" do
|
125
|
-
create_test_posts_table(primary_key_trigger: true, primary_key: "post_id")
|
126
|
-
expect(standard_dump).to match(/create_table "test_posts", primary_key: "post_id".*add_primary_key_trigger "test_posts", primary_key: "post_id"/m)
|
127
|
-
end
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
111
|
describe "foreign key constraints" do
|
132
112
|
before(:all) do
|
133
113
|
schema_define do
|
@@ -235,7 +215,6 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
235
215
|
output = dump_table_schema "test_comments"
|
236
216
|
expect(output).to match(/add_foreign_key "test_comments", "test_posts", column: "baz_id", primary_key: "baz_id", name: "test_comments_baz_id_fk"/)
|
237
217
|
end
|
238
|
-
|
239
218
|
end
|
240
219
|
|
241
220
|
describe "synonyms" do
|
@@ -252,13 +231,6 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
252
231
|
expect(standard_dump).to match(/add_synonym "test_synonym", "schema_name.table_name", force: true/)
|
253
232
|
end
|
254
233
|
|
255
|
-
it "should include synonym to other database table in schema dump" do
|
256
|
-
schema_define do
|
257
|
-
add_synonym :test_synonym, "table_name@link_name", force: true
|
258
|
-
end
|
259
|
-
expect(standard_dump).to match(/add_synonym "test_synonym", "table_name@link_name(\.[-A-Za-z0-9_]+)*", force: true/)
|
260
|
-
end
|
261
|
-
|
262
234
|
it "should not include ignored table names in schema dump" do
|
263
235
|
schema_define do
|
264
236
|
add_synonym :test_synonym, "schema_name.table_name", force: true
|
@@ -279,7 +251,6 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
279
251
|
end
|
280
252
|
expect(standard_dump(ignore_tables: [ /table_name/i ])).to match(/add_synonym "test_synonym"/)
|
281
253
|
end
|
282
|
-
|
283
254
|
end
|
284
255
|
|
285
256
|
describe "temporary tables" do
|
@@ -319,7 +290,6 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
319
290
|
output = dump_table_schema "test_posts"
|
320
291
|
expect(output).to match(/t\.index \["NVL\(\\"CREATED_AT\\",\\"UPDATED_AT\\"\)"\], name: "index_test_posts_cr_upd_at"$/)
|
321
292
|
end
|
322
|
-
|
323
293
|
end
|
324
294
|
|
325
295
|
describe "materialized views" do
|