activerecord-oracle_enhanced-adapter 5.2.8 → 7.0.3
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 +390 -21
- data/README.md +35 -8
- data/VERSION +1 -1
- data/lib/active_record/connection_adapters/emulation/oracle_adapter.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/column.rb +3 -3
- data/lib/active_record/connection_adapters/oracle_enhanced/connection.rb +42 -37
- data/lib/active_record/connection_adapters/oracle_enhanced/context_index.rb +59 -60
- data/lib/active_record/connection_adapters/oracle_enhanced/database_limits.rb +5 -10
- data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +86 -81
- data/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb +9 -10
- data/lib/active_record/connection_adapters/oracle_enhanced/dbms_output.rb +1 -2
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +37 -16
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/lob.rb +5 -6
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +58 -49
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_quoting.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/procedures.rb +6 -7
- data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +75 -51
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +13 -14
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +14 -4
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb +27 -24
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +156 -155
- data/lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb +103 -90
- data/lib/active_record/connection_adapters/oracle_enhanced/type_metadata.rb +3 -2
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +261 -161
- data/lib/active_record/type/oracle_enhanced/boolean.rb +0 -1
- data/lib/active_record/type/oracle_enhanced/character_string.rb +36 -0
- data/lib/active_record/type/oracle_enhanced/integer.rb +0 -1
- data/lib/arel/visitors/oracle.rb +221 -0
- data/lib/arel/visitors/oracle12.rb +128 -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 +78 -26
- data/spec/active_record/connection_adapters/oracle_enhanced/context_index_spec.rb +7 -15
- data/spec/active_record/connection_adapters/oracle_enhanced/database_tasks_spec.rb +5 -0
- data/spec/active_record/connection_adapters/oracle_enhanced/dbms_output_spec.rb +17 -17
- data/spec/active_record/connection_adapters/oracle_enhanced/procedures_spec.rb +7 -10
- 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 +33 -36
- data/spec/active_record/connection_adapters/oracle_enhanced/schema_statements_spec.rb +77 -258
- data/spec/active_record/connection_adapters/oracle_enhanced/structure_dump_spec.rb +38 -39
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +273 -85
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +7 -8
- data/spec/active_record/oracle_enhanced/type/boolean_spec.rb +2 -4
- data/spec/active_record/oracle_enhanced/type/character_string_spec.rb +43 -0
- data/spec/active_record/oracle_enhanced/type/custom_spec.rb +90 -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/integer_spec.rb +2 -2
- data/spec/active_record/oracle_enhanced/type/json_spec.rb +0 -1
- data/spec/active_record/oracle_enhanced/type/national_character_string_spec.rb +6 -5
- data/spec/active_record/oracle_enhanced/type/timestamp_spec.rb +2 -4
- data/spec/spec_config.yaml.template +2 -2
- data/spec/spec_helper.rb +13 -2
- metadata +52 -30
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements_ext.rb +0 -28
@@ -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
|
@@ -330,7 +326,7 @@ describe "OracleEnhancedAdapter context index" do
|
|
330
326
|
it "should dump definition of single column index" do
|
331
327
|
@conn.add_context_index :posts, :title
|
332
328
|
output = dump_table_schema "posts"
|
333
|
-
expect(output).to match(/add_context_index "posts", \["title"\], name:
|
329
|
+
expect(output).to match(/add_context_index "posts", \["title"\], name: "index_posts_on_title"$/)
|
334
330
|
@conn.remove_context_index :posts, :title
|
335
331
|
end
|
336
332
|
|
@@ -379,10 +375,9 @@ describe "OracleEnhancedAdapter context index" do
|
|
379
375
|
sub_query = "SELECT comments.author AS comment_author, comments.body AS comment_body\nFROM comments\nWHERE comments.post_id = :id"
|
380
376
|
@conn.add_context_index :posts, [:title, :body, sub_query], options
|
381
377
|
output = dump_table_schema "posts"
|
382
|
-
expect(output).to match(/add_context_index "posts", \[:title, :body, "#{sub_query.
|
378
|
+
expect(output).to match(/add_context_index "posts", \[:title, :body, "#{sub_query.tr("\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
|
@@ -20,6 +20,11 @@ describe "Oracle Enhanced adapter database tasks" do
|
|
20
20
|
query = "SELECT COUNT(*) FROM dba_users WHERE UPPER(username) = '#{new_user_config[:username].upcase}'"
|
21
21
|
expect(ActiveRecord::Base.connection.select_value(query)).to eq(1)
|
22
22
|
end
|
23
|
+
it "grants permissions defined by OracleEnhancedAdapter.persmissions" do
|
24
|
+
query = "SELECT COUNT(*) FROM DBA_SYS_PRIVS WHERE GRANTEE = '#{new_user_config[:username].upcase}'"
|
25
|
+
permissions_count = ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.permissions.size
|
26
|
+
expect(ActiveRecord::Base.connection.select_value(query)).to eq(permissions_count)
|
27
|
+
end
|
23
28
|
after do
|
24
29
|
ActiveRecord::Base.connection.execute("DROP USER #{new_user_config[:username]}")
|
25
30
|
end
|
@@ -5,23 +5,23 @@ describe "OracleEnhancedAdapter logging dbms_output from plsql" do
|
|
5
5
|
|
6
6
|
before(:all) do
|
7
7
|
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
8
|
-
ActiveRecord::Base.connection.execute
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
8
|
+
ActiveRecord::Base.connection.execute <<~SQL
|
9
|
+
CREATE or REPLACE
|
10
|
+
FUNCTION MORE_THAN_FIVE_CHARACTERS_LONG (some_text VARCHAR2) RETURN INTEGER
|
11
|
+
AS
|
12
|
+
longer_than_five INTEGER;
|
13
|
+
BEGIN
|
14
|
+
dbms_output.put_line('before the if -' || some_text || '-');
|
15
|
+
IF length(some_text) > 5 THEN
|
16
|
+
dbms_output.put_line('it is longer than 5');
|
17
|
+
longer_than_five := 1;
|
18
|
+
ELSE
|
19
|
+
dbms_output.put_line('it is 5 or shorter');
|
20
|
+
longer_than_five := 0;
|
21
|
+
END IF;
|
22
|
+
dbms_output.put_line('about to return: ' || longer_than_five);
|
23
|
+
RETURN longer_than_five;
|
24
|
+
END;
|
25
25
|
SQL
|
26
26
|
end
|
27
27
|
|
@@ -23,7 +23,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
23
23
|
t.timestamps null: true
|
24
24
|
end
|
25
25
|
end
|
26
|
-
@conn.execute
|
26
|
+
@conn.execute <<~SQL
|
27
27
|
CREATE OR REPLACE PACKAGE test_employees_pkg IS
|
28
28
|
PROCEDURE create_employee(
|
29
29
|
p_first_name VARCHAR2,
|
@@ -43,7 +43,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
43
43
|
p_employee_id NUMBER);
|
44
44
|
END;
|
45
45
|
SQL
|
46
|
-
@conn.execute
|
46
|
+
@conn.execute <<~SQL
|
47
47
|
CREATE OR REPLACE PACKAGE BODY test_employees_pkg IS
|
48
48
|
PROCEDURE create_employee(
|
49
49
|
p_first_name VARCHAR2,
|
@@ -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
|
@@ -134,7 +133,6 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
134
133
|
end
|
135
134
|
|
136
135
|
private
|
137
|
-
|
138
136
|
def raise_make_transaction_rollback
|
139
137
|
raise "Make the transaction rollback"
|
140
138
|
end
|
@@ -212,8 +210,8 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
212
210
|
expect(@employee.first_name).to eq("First")
|
213
211
|
end
|
214
212
|
|
215
|
-
it "should not update record if nothing is changed and partial
|
216
|
-
TestEmployee.
|
213
|
+
it "should not update record if nothing is changed and partial updates are enabled" do
|
214
|
+
TestEmployee.partial_updates = true
|
217
215
|
@employee = TestEmployee.create(
|
218
216
|
first_name: "First",
|
219
217
|
last_name: "Last",
|
@@ -225,8 +223,8 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
225
223
|
expect(@employee.version).to eq(1)
|
226
224
|
end
|
227
225
|
|
228
|
-
it "should update record if nothing is changed and partial
|
229
|
-
TestEmployee.
|
226
|
+
it "should update record if nothing is changed and partial updates are disabled" do
|
227
|
+
TestEmployee.partial_updates = false
|
230
228
|
@employee = TestEmployee.create(
|
231
229
|
first_name: "First",
|
232
230
|
last_name: "Last",
|
@@ -318,7 +316,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
318
316
|
end
|
319
317
|
|
320
318
|
it "should log update record" do
|
321
|
-
(TestEmployee.
|
319
|
+
(TestEmployee.partial_updates = false) rescue nil
|
322
320
|
@employee = TestEmployee.create(
|
323
321
|
first_name: "First",
|
324
322
|
last_name: "Last",
|
@@ -361,5 +359,4 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
361
359
|
expect(@employee.save).to be_falsey
|
362
360
|
expect(@employee.errors[:first_name]).not_to be_blank
|
363
361
|
end
|
364
|
-
|
365
362
|
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,9 +19,9 @@ 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
|
-
create_table :test_posts, options do |t|
|
24
|
+
create_table :test_posts, **options do |t|
|
25
25
|
t.string :title
|
26
26
|
t.timestamps null: true
|
27
27
|
end
|
@@ -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
|
@@ -72,7 +71,7 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
72
71
|
|
73
72
|
it "should be able to dump default values using special characters" do
|
74
73
|
output = dump_table_schema "test_defaults"
|
75
|
-
expect(output).to match(/t.string
|
74
|
+
expect(output).to match(/t.string "special_c", default: "\\n"/)
|
76
75
|
end
|
77
76
|
end
|
78
77
|
|
@@ -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
|
@@ -106,28 +104,10 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
106
104
|
|
107
105
|
it "should be able to dump ntext columns" do
|
108
106
|
output = dump_table_schema "test_ntexts"
|
109
|
-
expect(output).to match(/t.ntext
|
107
|
+
expect(output).to match(/t.ntext "ntext_column"/)
|
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
|
@@ -227,7 +207,7 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
227
207
|
end
|
228
208
|
end
|
229
209
|
|
230
|
-
@conn.execute
|
210
|
+
@conn.execute <<~SQL
|
231
211
|
ALTER TABLE TEST_COMMENTS
|
232
212
|
ADD CONSTRAINT TEST_COMMENTS_BAZ_ID_FK FOREIGN KEY (baz_id) REFERENCES test_posts(baz_id)
|
233
213
|
SQL
|
@@ -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
|
@@ -335,6 +305,33 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
335
305
|
end
|
336
306
|
end
|
337
307
|
|
308
|
+
describe "context indexes" do
|
309
|
+
before(:each) do
|
310
|
+
schema_define do
|
311
|
+
create_table :test_context_indexed_posts, force: true do |t|
|
312
|
+
t.string :title
|
313
|
+
t.string :body
|
314
|
+
t.index :title
|
315
|
+
end
|
316
|
+
add_context_index :test_context_indexed_posts, :body, sync: "ON COMMIT"
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
after(:each) do
|
321
|
+
schema_define do
|
322
|
+
drop_table :test_context_indexed_posts
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
it "should dump the context index" do
|
327
|
+
expect(standard_dump).to include(%(add_context_index "test_context_indexed_posts", ["body"]))
|
328
|
+
end
|
329
|
+
|
330
|
+
it "dumps the sync option" do
|
331
|
+
expect(standard_dump).to include(%(sync: "ON COMMIT"))
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
338
335
|
describe "virtual columns" do
|
339
336
|
before(:all) do
|
340
337
|
skip "Not supported in this database version" unless @oracle11g_or_higher
|
@@ -373,7 +370,7 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
373
370
|
expect(output).to match(/t\.virtual "full_name",(\s*)type: :string,(\s*)limit: 512,(\s*)as: "\\"FIRST_NAME\\"\|\|', '\|\|\\"LAST_NAME\\""/)
|
374
371
|
expect(output).to match(/t\.virtual "short_name",(\s*)type: :string,(\s*)limit: 300,(\s*)as:(.*)/)
|
375
372
|
expect(output).to match(/t\.virtual "full_name_length",(\s*)type: :integer,(\s*)precision: 38,(\s*)as:(.*)/)
|
376
|
-
expect(output).to match(/t\.virtual "name_ratio",(\s*)as:(.*)
|
373
|
+
expect(output).to match(/t\.virtual "name_ratio",(\s*)as:(.*)"$/) # no :type
|
377
374
|
expect(output).to match(/t\.virtual "abbrev_name",(\s*)type: :string,(\s*)limit: 100,(\s*)as:(.*)/)
|
378
375
|
expect(output).to match(/t\.virtual "field_with_leading_space",(\s*)type: :string,(\s*)limit: 300,(\s*)as: "' '\|\|\\"FIRST_NAME\\"\|\|' '"/)
|
379
376
|
end
|