activerecord-oracle_enhanced-adapter 5.2.8 → 7.0.3
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,24 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module ActiveRecord
|
4
|
-
module ConnectionAdapters
|
5
|
-
module OracleEnhanced
|
6
|
-
module StructureDump
|
3
|
+
module ActiveRecord # :nodoc:
|
4
|
+
module ConnectionAdapters # :nodoc:
|
5
|
+
module OracleEnhanced # :nodoc:
|
6
|
+
module StructureDump # :nodoc:
|
7
7
|
# Statements separator used in structure dump to allow loading of structure dump also with SQL*Plus
|
8
8
|
STATEMENT_TOKEN = "\n\n/\n\n"
|
9
9
|
|
10
|
-
def structure_dump
|
11
|
-
sequences = select(
|
12
|
-
SELECT
|
10
|
+
def structure_dump # :nodoc:
|
11
|
+
sequences = select(<<~SQL.squish, "SCHEMA")
|
12
|
+
SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */
|
13
|
+
sequence_name, min_value, max_value, increment_by, order_flag, cycle_flag
|
13
14
|
FROM all_sequences
|
14
|
-
where sequence_owner = SYS_CONTEXT('userenv', '
|
15
|
+
where sequence_owner = SYS_CONTEXT('userenv', 'current_schema') ORDER BY 1
|
15
16
|
SQL
|
16
17
|
|
17
18
|
structure = sequences.map do |result|
|
18
19
|
"CREATE SEQUENCE #{quote_table_name(result["sequence_name"])} MINVALUE #{result["min_value"]} MAXVALUE #{result["max_value"]} INCREMENT BY #{result["increment_by"]} #{result["order_flag"] == 'Y' ? "ORDER" : "NOORDER"} #{result["cycle_flag"] == 'Y' ? "CYCLE" : "NOCYCLE"}"
|
19
20
|
end
|
20
|
-
tables = select_values(
|
21
|
-
SELECT table_name FROM all_tables t
|
21
|
+
tables = select_values(<<~SQL.squish, "SCHEMA")
|
22
|
+
SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ table_name FROM all_tables t
|
22
23
|
WHERE owner = SYS_CONTEXT('userenv', 'current_schema') AND secondary = 'N'
|
23
24
|
AND NOT EXISTS (SELECT mv.mview_name FROM all_mviews mv
|
24
25
|
WHERE mv.owner = t.owner AND mv.mview_name = t.table_name)
|
@@ -28,13 +29,13 @@ module ActiveRecord #:nodoc:
|
|
28
29
|
SQL
|
29
30
|
tables.each do |table_name|
|
30
31
|
virtual_columns = virtual_columns_for(table_name) if supports_virtual_columns?
|
31
|
-
ddl = "CREATE#{ ' GLOBAL TEMPORARY' if temporary_table?(table_name)} TABLE \"#{table_name}\" (\n"
|
32
|
-
columns = select_all(
|
33
|
-
SELECT column_name, data_type, data_length, char_used, char_length,
|
32
|
+
ddl = +"CREATE#{ ' GLOBAL TEMPORARY' if temporary_table?(table_name)} TABLE \"#{table_name}\" (\n"
|
33
|
+
columns = select_all(<<~SQL.squish, "SCHEMA", [bind_string("table_name", table_name)])
|
34
|
+
SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ column_name, data_type, data_length, char_used, char_length,
|
34
35
|
data_precision, data_scale, data_default, nullable
|
35
36
|
FROM all_tab_columns
|
36
|
-
WHERE table_name =
|
37
|
-
AND owner = SYS_CONTEXT('userenv', '
|
37
|
+
WHERE table_name = :table_name
|
38
|
+
AND owner = SYS_CONTEXT('userenv', 'current_schema')
|
38
39
|
ORDER BY column_id
|
39
40
|
SQL
|
40
41
|
cols = columns.map do |row|
|
@@ -54,11 +55,13 @@ module ActiveRecord #:nodoc:
|
|
54
55
|
structure << structure_dump_column_comments(table_name)
|
55
56
|
end
|
56
57
|
|
57
|
-
join_with_statement_token(structure) <<
|
58
|
+
join_with_statement_token(structure) <<
|
59
|
+
structure_dump_fk_constraints <<
|
60
|
+
structure_dump_views
|
58
61
|
end
|
59
62
|
|
60
|
-
def structure_dump_column(column)
|
61
|
-
col = "\"#{column['column_name']}\" #{column['data_type']}"
|
63
|
+
def structure_dump_column(column) # :nodoc:
|
64
|
+
col = +"\"#{column['column_name']}\" #{column['data_type']}"
|
62
65
|
if (column["data_type"] == "NUMBER") && !column["data_precision"].nil?
|
63
66
|
col << "(#{column['data_precision'].to_i}"
|
64
67
|
col << ",#{column['data_scale'].to_i}" if !column["data_scale"].nil?
|
@@ -72,9 +75,9 @@ module ActiveRecord #:nodoc:
|
|
72
75
|
col
|
73
76
|
end
|
74
77
|
|
75
|
-
def structure_dump_virtual_column(column, data_default)
|
76
|
-
data_default = data_default.
|
77
|
-
col = "\"#{column['column_name']}\" #{column['data_type']}"
|
78
|
+
def structure_dump_virtual_column(column, data_default) # :nodoc:
|
79
|
+
data_default = data_default.delete('"')
|
80
|
+
col = +"\"#{column['column_name']}\" #{column['data_type']}"
|
78
81
|
if (column["data_type"] == "NUMBER") && !column["data_precision"].nil?
|
79
82
|
col << "(#{column['data_precision'].to_i}"
|
80
83
|
col << ",#{column['data_scale'].to_i}" if !column["data_scale"].nil?
|
@@ -86,18 +89,18 @@ module ActiveRecord #:nodoc:
|
|
86
89
|
col << " GENERATED ALWAYS AS (#{data_default}) VIRTUAL"
|
87
90
|
end
|
88
91
|
|
89
|
-
def structure_dump_primary_key(table)
|
92
|
+
def structure_dump_primary_key(table) # :nodoc:
|
90
93
|
opts = { name: "", cols: [] }
|
91
|
-
pks = select_all(
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
94
|
+
pks = select_all(<<~SQL.squish, "SCHEMA")
|
95
|
+
SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ a.constraint_name, a.column_name, a.position
|
96
|
+
FROM all_cons_columns a
|
97
|
+
JOIN all_constraints c
|
98
|
+
ON a.constraint_name = c.constraint_name
|
99
|
+
WHERE c.table_name = '#{table.upcase}'
|
100
|
+
AND c.constraint_type = 'P'
|
101
|
+
AND a.owner = c.owner
|
102
|
+
AND c.owner = SYS_CONTEXT('userenv', 'current_schema')
|
103
|
+
SQL
|
101
104
|
pks.each do |row|
|
102
105
|
opts[:name] = row["constraint_name"]
|
103
106
|
opts[:cols][row["position"] - 1] = row["column_name"]
|
@@ -105,18 +108,18 @@ module ActiveRecord #:nodoc:
|
|
105
108
|
opts[:cols].length > 0 ? ",\n CONSTRAINT #{opts[:name]} PRIMARY KEY (#{opts[:cols].join(',')})" : ""
|
106
109
|
end
|
107
110
|
|
108
|
-
def structure_dump_unique_keys(table)
|
111
|
+
def structure_dump_unique_keys(table) # :nodoc:
|
109
112
|
keys = {}
|
110
|
-
uks = select_all(
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
113
|
+
uks = select_all(<<~SQL.squish, "SCHEMA")
|
114
|
+
SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ a.constraint_name, a.column_name, a.position
|
115
|
+
FROM all_cons_columns a
|
116
|
+
JOIN all_constraints c
|
117
|
+
ON a.constraint_name = c.constraint_name
|
118
|
+
WHERE c.table_name = '#{table.upcase}'
|
119
|
+
AND c.constraint_type = 'U'
|
120
|
+
AND a.owner = c.owner
|
121
|
+
AND c.owner = SYS_CONTEXT('userenv', 'current_schema')
|
122
|
+
SQL
|
120
123
|
uks.each do |uk|
|
121
124
|
keys[uk["constraint_name"]] ||= []
|
122
125
|
keys[uk["constraint_name"]][uk["position"] - 1] = uk["column_name"]
|
@@ -126,7 +129,7 @@ module ActiveRecord #:nodoc:
|
|
126
129
|
end
|
127
130
|
end
|
128
131
|
|
129
|
-
def structure_dump_indexes(table_name)
|
132
|
+
def structure_dump_indexes(table_name) # :nodoc:
|
130
133
|
indexes(table_name).map do |options|
|
131
134
|
column_names = options.columns
|
132
135
|
options = { name: options.name, unique: options.unique }
|
@@ -142,15 +145,15 @@ module ActiveRecord #:nodoc:
|
|
142
145
|
end
|
143
146
|
end
|
144
147
|
|
145
|
-
def structure_dump_fk_constraints
|
146
|
-
foreign_keys = select_all(
|
147
|
-
SELECT table_name FROM all_tables
|
148
|
+
def structure_dump_fk_constraints # :nodoc:
|
149
|
+
foreign_keys = select_all(<<~SQL.squish, "SCHEMA")
|
150
|
+
SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ table_name FROM all_tables
|
148
151
|
WHERE owner = SYS_CONTEXT('userenv', 'current_schema') ORDER BY 1
|
149
152
|
SQL
|
150
153
|
fks = foreign_keys.map do |table|
|
151
154
|
if respond_to?(:foreign_keys) && (foreign_keys = foreign_keys(table["table_name"])).any?
|
152
155
|
foreign_keys.map do |fk|
|
153
|
-
sql = "ALTER TABLE #{quote_table_name(fk.from_table)} ADD CONSTRAINT #{quote_column_name(fk.options[:name])} "
|
156
|
+
sql = +"ALTER TABLE #{quote_table_name(fk.from_table)} ADD CONSTRAINT #{quote_column_name(fk.options[:name])} "
|
154
157
|
sql << "#{foreign_key_definition(fk.to_table, fk.options)}"
|
155
158
|
end
|
156
159
|
end
|
@@ -171,9 +174,10 @@ module ActiveRecord #:nodoc:
|
|
171
174
|
|
172
175
|
def structure_dump_column_comments(table_name)
|
173
176
|
comments = []
|
174
|
-
columns = select_values(
|
175
|
-
SELECT column_name FROM
|
176
|
-
WHERE
|
177
|
+
columns = select_values(<<~SQL.squish, "SCHEMA", [bind_string("table_name", table_name)])
|
178
|
+
SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ column_name FROM all_tab_columns
|
179
|
+
WHERE owner = SYS_CONTEXT('userenv', 'current_schema')
|
180
|
+
AND table_name = :table_name ORDER BY column_id
|
177
181
|
SQL
|
178
182
|
|
179
183
|
columns.each do |column|
|
@@ -186,7 +190,7 @@ module ActiveRecord #:nodoc:
|
|
186
190
|
join_with_statement_token(comments)
|
187
191
|
end
|
188
192
|
|
189
|
-
def foreign_key_definition(to_table, options = {})
|
193
|
+
def foreign_key_definition(to_table, options = {}) # :nodoc:
|
190
194
|
column_sql = quote_column_name(options[:column] || "#{to_table.to_s.singularize}_id")
|
191
195
|
references = options[:references] ? options[:references].first : nil
|
192
196
|
references_sql = quote_column_name(options[:primary_key] || references || "id")
|
@@ -202,23 +206,23 @@ module ActiveRecord #:nodoc:
|
|
202
206
|
sql
|
203
207
|
end
|
204
208
|
|
205
|
-
# Extract all stored procedures, packages, synonyms
|
206
|
-
def structure_dump_db_stored_code
|
209
|
+
# Extract all stored procedures, packages, synonyms.
|
210
|
+
def structure_dump_db_stored_code # :nodoc:
|
207
211
|
structure = []
|
208
|
-
all_source = select_all(
|
209
|
-
SELECT DISTINCT name, type
|
212
|
+
all_source = select_all(<<~SQL.squish, "SCHEMA")
|
213
|
+
SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ DISTINCT name, type
|
210
214
|
FROM all_source
|
211
215
|
WHERE type IN ('PROCEDURE', 'PACKAGE', 'PACKAGE BODY', 'FUNCTION', 'TRIGGER', 'TYPE')
|
212
216
|
AND name NOT LIKE 'BIN$%'
|
213
217
|
AND owner = SYS_CONTEXT('userenv', 'current_schema') ORDER BY type
|
214
218
|
SQL
|
215
219
|
all_source.each do |source|
|
216
|
-
ddl = "CREATE OR REPLACE \n"
|
217
|
-
texts = select_all(
|
218
|
-
SELECT text
|
220
|
+
ddl = +"CREATE OR REPLACE \n"
|
221
|
+
texts = select_all(<<~SQL.squish, "all source at structure dump", [bind_string("source_name", source["name"]), bind_string("source_type", source["type"])])
|
222
|
+
SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ text
|
219
223
|
FROM all_source
|
220
|
-
WHERE name =
|
221
|
-
AND type =
|
224
|
+
WHERE name = :source_name
|
225
|
+
AND type = :source_type
|
222
226
|
AND owner = SYS_CONTEXT('userenv', 'current_schema')
|
223
227
|
ORDER BY line
|
224
228
|
SQL
|
@@ -229,38 +233,48 @@ module ActiveRecord #:nodoc:
|
|
229
233
|
structure << ddl
|
230
234
|
end
|
231
235
|
|
232
|
-
# export
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
+
# export synonyms
|
237
|
+
structure << structure_dump_synonyms
|
238
|
+
|
239
|
+
join_with_statement_token(structure)
|
240
|
+
end
|
241
|
+
|
242
|
+
def structure_dump_views # :nodoc:
|
243
|
+
structure = []
|
244
|
+
views = select_all(<<~SQL.squish, "SCHEMA")
|
245
|
+
SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ view_name, text FROM all_views
|
246
|
+
WHERE owner = SYS_CONTEXT('userenv', 'current_schema') ORDER BY view_name ASC
|
236
247
|
SQL
|
237
248
|
views.each do |view|
|
238
249
|
structure << "CREATE OR REPLACE FORCE VIEW #{view['view_name']} AS\n #{view['text']}"
|
239
250
|
end
|
251
|
+
join_with_statement_token(structure)
|
252
|
+
end
|
240
253
|
|
241
|
-
|
242
|
-
|
243
|
-
|
254
|
+
def structure_dump_synonyms # :nodoc:
|
255
|
+
structure = []
|
256
|
+
synonyms = select_all(<<~SQL.squish, "SCHEMA")
|
257
|
+
SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ owner, synonym_name, table_name, table_owner
|
244
258
|
FROM all_synonyms
|
245
259
|
WHERE owner = SYS_CONTEXT('userenv', 'current_schema')
|
246
260
|
SQL
|
247
261
|
synonyms.each do |synonym|
|
248
262
|
structure << "CREATE OR REPLACE #{synonym['owner'] == 'PUBLIC' ? 'PUBLIC' : '' } SYNONYM #{synonym['synonym_name']}
|
249
|
-
|
263
|
+
FOR #{synonym['table_owner']}.#{synonym['table_name']}"
|
250
264
|
end
|
251
|
-
|
252
265
|
join_with_statement_token(structure)
|
253
266
|
end
|
254
267
|
|
255
|
-
def structure_drop
|
256
|
-
sequences = select_values(
|
257
|
-
SELECT
|
268
|
+
def structure_drop # :nodoc:
|
269
|
+
sequences = select_values(<<~SQL.squish, "SCHEMA")
|
270
|
+
SELECT/*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */
|
271
|
+
sequence_name FROM all_sequences where sequence_owner = SYS_CONTEXT('userenv', 'current_schema') ORDER BY 1
|
258
272
|
SQL
|
259
273
|
statements = sequences.map do |seq|
|
260
274
|
"DROP SEQUENCE \"#{seq}\""
|
261
275
|
end
|
262
|
-
tables = select_values(
|
263
|
-
SELECT table_name from all_tables t
|
276
|
+
tables = select_values(<<~SQL.squish, "SCHEMA")
|
277
|
+
SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ table_name from all_tables t
|
264
278
|
WHERE owner = SYS_CONTEXT('userenv', 'current_schema') AND secondary = 'N'
|
265
279
|
AND NOT EXISTS (SELECT mv.mview_name FROM all_mviews mv
|
266
280
|
WHERE mv.owner = t.owner AND mv.mview_name = t.table_name)
|
@@ -274,9 +288,9 @@ module ActiveRecord #:nodoc:
|
|
274
288
|
join_with_statement_token(statements)
|
275
289
|
end
|
276
290
|
|
277
|
-
def temp_table_drop
|
278
|
-
temporary_tables = select_values(
|
279
|
-
SELECT table_name FROM all_tables
|
291
|
+
def temp_table_drop # :nodoc:
|
292
|
+
temporary_tables = select_values(<<~SQL.squish, "SCHEMA")
|
293
|
+
SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ table_name FROM all_tables
|
280
294
|
WHERE owner = SYS_CONTEXT('userenv', 'current_schema')
|
281
295
|
AND secondary = 'N' AND temporary = 'Y' ORDER BY 1
|
282
296
|
SQL
|
@@ -286,7 +300,7 @@ module ActiveRecord #:nodoc:
|
|
286
300
|
join_with_statement_token(statements)
|
287
301
|
end
|
288
302
|
|
289
|
-
def full_drop(preserve_tables = false)
|
303
|
+
def full_drop(preserve_tables = false) # :nodoc:
|
290
304
|
s = preserve_tables ? [] : [structure_drop]
|
291
305
|
s << temp_table_drop if preserve_tables
|
292
306
|
s << drop_sql_for_feature("view")
|
@@ -306,24 +320,23 @@ module ActiveRecord #:nodoc:
|
|
306
320
|
end
|
307
321
|
|
308
322
|
private
|
309
|
-
|
310
323
|
# Called only if `supports_virtual_columns?` returns true
|
311
324
|
# return [{'column_name' => 'FOOS', 'data_default' => '...'}, ...]
|
312
325
|
def virtual_columns_for(table)
|
313
|
-
select_all(
|
314
|
-
SELECT column_name, data_default
|
326
|
+
select_all(<<~SQL.squish, "SCHEMA", [bind_string("table_name", table.upcase)])
|
327
|
+
SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ column_name, data_default
|
315
328
|
FROM all_tab_cols
|
316
329
|
WHERE virtual_column = 'YES'
|
317
|
-
AND owner = SYS_CONTEXT('userenv', '
|
318
|
-
AND table_name =
|
330
|
+
AND owner = SYS_CONTEXT('userenv', 'current_schema')
|
331
|
+
AND table_name = :table_name
|
319
332
|
SQL
|
320
333
|
end
|
321
334
|
|
322
335
|
def drop_sql_for_feature(type)
|
323
336
|
short_type = type == "materialized view" ? "mview" : type
|
324
|
-
features = select_values(
|
325
|
-
SELECT #{short_type}_name FROM all_#{short_type.tableize}
|
326
|
-
where owner = SYS_CONTEXT('userenv', '
|
337
|
+
features = select_values(<<~SQL.squish, "SCHEMA")
|
338
|
+
SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ #{short_type}_name FROM all_#{short_type.tableize}
|
339
|
+
where owner = SYS_CONTEXT('userenv', 'current_schema')
|
327
340
|
SQL
|
328
341
|
statements = features.map do |name|
|
329
342
|
"DROP #{type.upcase} \"#{name}\""
|
@@ -332,9 +345,9 @@ module ActiveRecord #:nodoc:
|
|
332
345
|
end
|
333
346
|
|
334
347
|
def drop_sql_for_object(type)
|
335
|
-
objects = select_values(
|
336
|
-
SELECT object_name FROM all_objects
|
337
|
-
WHERE object_type = '#{type.upcase}' and owner = SYS_CONTEXT('userenv', '
|
348
|
+
objects = select_values(<<~SQL.squish, "SCHEMA")
|
349
|
+
SELECT /*+ OPTIMIZER_FEATURES_ENABLE('11.2.0.2') */ object_name FROM all_objects
|
350
|
+
WHERE object_type = '#{type.upcase}' and owner = SYS_CONTEXT('userenv', 'current_schema')
|
338
351
|
SQL
|
339
352
|
statements = objects.map do |name|
|
340
353
|
"DROP #{type.upcase} \"#{name}\""
|
@@ -1,9 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module ActiveRecord
|
4
|
-
module ConnectionAdapters
|
4
|
+
module ConnectionAdapters # :nodoc:
|
5
5
|
module OracleEnhanced
|
6
6
|
class TypeMetadata < DelegateClass(ActiveRecord::ConnectionAdapters::SqlTypeMetadata) # :nodoc:
|
7
|
+
include Deduplicable
|
8
|
+
|
7
9
|
attr_reader :virtual
|
8
10
|
|
9
11
|
def initialize(type_metadata, virtual: nil)
|
@@ -23,7 +25,6 @@ module ActiveRecord
|
|
23
25
|
end
|
24
26
|
|
25
27
|
protected
|
26
|
-
|
27
28
|
def attributes_for_hash
|
28
29
|
[self.class, @type_metadata, virtual]
|
29
30
|
end
|