activerecord-oracle_enhanced-adapter 1.5.6 → 1.6.0
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/Gemfile +2 -2
- data/History.md +107 -0
- data/README.md +271 -174
- data/VERSION +1 -1
- data/activerecord-oracle_enhanced-adapter.gemspec +26 -22
- data/lib/active_record/connection_adapters/{oracle_enhanced_column.rb → oracle_enhanced/column.rb} +14 -63
- data/lib/active_record/connection_adapters/oracle_enhanced/column_dumper.rb +65 -0
- data/lib/active_record/connection_adapters/{oracle_enhanced_connection.rb → oracle_enhanced/connection.rb} +2 -2
- data/lib/active_record/connection_adapters/oracle_enhanced/context_index.rb +347 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +257 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/dirty.rb +40 -0
- data/lib/active_record/connection_adapters/{oracle_enhanced_schema_creation.rb → oracle_enhanced/schema_creation.rb} +17 -16
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +95 -0
- data/lib/active_record/connection_adapters/{oracle_enhanced_schema_dumper.rb → oracle_enhanced/schema_dumper.rb} +4 -32
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +546 -0
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements_ext.rb +65 -0
- data/lib/active_record/connection_adapters/{oracle_enhanced_structure_dump.rb → oracle_enhanced/structure_dump.rb} +26 -4
- data/lib/active_record/connection_adapters/oracle_enhanced/version.rb +1 -0
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +159 -66
- data/lib/active_record/oracle_enhanced/type/integer.rb +13 -0
- data/lib/active_record/oracle_enhanced/type/raw.rb +13 -0
- data/lib/active_record/oracle_enhanced/type/timestamp.rb +11 -0
- data/lib/activerecord-oracle_enhanced-adapter.rb +1 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +6 -31
- data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +1 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb +2 -2
- data/spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb +2 -2
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +63 -63
- data/spec/active_record/connection_adapters/oracle_enhanced_database_tasks_spec.rb +1 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +7 -13
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +25 -178
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +14 -5
- data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +1 -0
- data/spec/spec_config.yaml.template +10 -0
- data/spec/spec_helper.rb +21 -10
- metadata +27 -23
- data/lib/active_record/connection_adapters/oracle_enhanced_column_dumper.rb +0 -77
- data/lib/active_record/connection_adapters/oracle_enhanced_context_index.rb +0 -350
- data/lib/active_record/connection_adapters/oracle_enhanced_database_statements.rb +0 -262
- data/lib/active_record/connection_adapters/oracle_enhanced_dirty.rb +0 -45
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_definitions.rb +0 -197
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements.rb +0 -450
- data/lib/active_record/connection_adapters/oracle_enhanced_schema_statements_ext.rb +0 -258
- data/lib/active_record/connection_adapters/oracle_enhanced_version.rb +0 -1
- /data/lib/active_record/connection_adapters/{oracle_enhanced_cpk.rb → oracle_enhanced/cpk.rb} +0 -0
- /data/lib/active_record/connection_adapters/{oracle_enhanced_database_tasks.rb → oracle_enhanced/database_tasks.rb} +0 -0
- /data/lib/active_record/connection_adapters/{oracle_enhanced_jdbc_connection.rb → oracle_enhanced/jdbc_connection.rb} +0 -0
- /data/lib/active_record/connection_adapters/{oracle_enhanced_oci_connection.rb → oracle_enhanced/oci_connection.rb} +0 -0
- /data/lib/active_record/connection_adapters/{oracle_enhanced_procedures.rb → oracle_enhanced/procedures.rb} +0 -0
@@ -30,9 +30,13 @@
|
|
30
30
|
# portions Copyright 2005 Graham Jenkins
|
31
31
|
|
32
32
|
require 'active_record/connection_adapters/abstract_adapter'
|
33
|
-
require 'active_record/connection_adapters/
|
33
|
+
require 'active_record/connection_adapters/oracle_enhanced/connection'
|
34
|
+
require 'active_record/connection_adapters/oracle_enhanced/database_statements'
|
35
|
+
require 'active_record/connection_adapters/oracle_enhanced/schema_statements'
|
36
|
+
require 'active_record/connection_adapters/oracle_enhanced/column_dumper'
|
37
|
+
require 'active_record/connection_adapters/oracle_enhanced/context_index'
|
34
38
|
|
35
|
-
require 'active_record/connection_adapters/
|
39
|
+
require 'active_record/connection_adapters/oracle_enhanced/column'
|
36
40
|
|
37
41
|
require 'digest/sha1'
|
38
42
|
|
@@ -131,7 +135,7 @@ module ActiveRecord
|
|
131
135
|
|
132
136
|
def record_changed_lobs
|
133
137
|
@changed_lob_columns = self.class.lob_columns.select do |col|
|
134
|
-
|
138
|
+
self.attribute_changed?(col.name) && !self.class.readonly_attributes.to_a.include?(col.name)
|
135
139
|
end
|
136
140
|
end
|
137
141
|
end
|
@@ -218,6 +222,15 @@ module ActiveRecord
|
|
218
222
|
# * <tt>:nls_time_tz_format</tt>
|
219
223
|
#
|
220
224
|
class OracleEnhancedAdapter < AbstractAdapter
|
225
|
+
# TODO: Use relative
|
226
|
+
include ActiveRecord::ConnectionAdapters::OracleEnhanced::DatabaseStatements
|
227
|
+
include ActiveRecord::ConnectionAdapters::OracleEnhanced::SchemaStatements
|
228
|
+
include ActiveRecord::ConnectionAdapters::OracleEnhanced::ColumnDumper
|
229
|
+
include ActiveRecord::ConnectionAdapters::OracleEnhanced::ContextIndex
|
230
|
+
|
231
|
+
def schema_creation
|
232
|
+
OracleEnhanced::SchemaCreation.new self
|
233
|
+
end
|
221
234
|
|
222
235
|
##
|
223
236
|
# :singleton-method:
|
@@ -270,13 +283,6 @@ module ActiveRecord
|
|
270
283
|
cattr_accessor :emulate_dates_by_column_name
|
271
284
|
self.emulate_dates_by_column_name = false
|
272
285
|
|
273
|
-
##
|
274
|
-
# :singleton-method:
|
275
|
-
# Specify how `NUMBER` datatype columns, without precision and scale, are handled in Rails world.
|
276
|
-
# Default is :decimal and other valid option is :float. Be wary of setting it to other values.
|
277
|
-
cattr_accessor :number_datatype_coercion
|
278
|
-
self.number_datatype_coercion = :decimal
|
279
|
-
|
280
286
|
# Check column name to identify if it is Date (and not Time) column.
|
281
287
|
# Is used if +emulate_dates_by_column_name+ option is set to +true+.
|
282
288
|
# Override this method definition in initializer file if different Date column recognition is needed.
|
@@ -311,7 +317,7 @@ module ActiveRecord
|
|
311
317
|
# Is used if +emulate_integers_by_column_name+ option is set to +true+.
|
312
318
|
# Override this method definition in initializer file if different Integer column recognition is needed.
|
313
319
|
def self.is_integer_column?(name, table_name = nil)
|
314
|
-
|
320
|
+
name =~ /(^|_)id$/i
|
315
321
|
end
|
316
322
|
|
317
323
|
##
|
@@ -326,9 +332,9 @@ module ActiveRecord
|
|
326
332
|
# Check column name to identify if it is boolean (and not String) column.
|
327
333
|
# Is used if +emulate_booleans_from_strings+ option is set to +true+.
|
328
334
|
# Override this method definition in initializer file if different boolean column recognition is needed.
|
329
|
-
def self.is_boolean_column?(name,
|
330
|
-
return true if ["CHAR(1)","VARCHAR2(1)"].include?(
|
331
|
-
|
335
|
+
def self.is_boolean_column?(name, sql_type, table_name = nil)
|
336
|
+
return true if ["CHAR(1)","VARCHAR2(1)"].include?(sql_type)
|
337
|
+
sql_type =~ /^VARCHAR2/ && (name =~ /_flag$/i || name =~ /_yn$/i)
|
332
338
|
end
|
333
339
|
|
334
340
|
# How boolean value should be quoted to String.
|
@@ -383,21 +389,18 @@ module ActiveRecord
|
|
383
389
|
end
|
384
390
|
end
|
385
391
|
|
386
|
-
class BindSubstitution < Arel::Visitors::Oracle #:nodoc:
|
387
|
-
include Arel::Visitors::BindVisitor
|
388
|
-
end
|
389
|
-
|
390
392
|
def initialize(connection, logger, config) #:nodoc:
|
391
393
|
super(connection, logger)
|
392
394
|
@quoted_column_names, @quoted_table_names = {}, {}
|
393
395
|
@config = config
|
394
396
|
@statements = StatementPool.new(connection, config.fetch(:statement_limit) { 250 })
|
395
397
|
@enable_dbms_output = false
|
396
|
-
|
397
|
-
|
398
|
+
@visitor = Arel::Visitors::Oracle.new self
|
399
|
+
|
400
|
+
if self.class.type_cast_config_to_boolean(config.fetch(:prepared_statements) { true })
|
398
401
|
@prepared_statements = true
|
399
402
|
else
|
400
|
-
@
|
403
|
+
@prepared_statements = false
|
401
404
|
end
|
402
405
|
end
|
403
406
|
|
@@ -423,7 +426,13 @@ module ActiveRecord
|
|
423
426
|
true
|
424
427
|
end
|
425
428
|
|
426
|
-
|
429
|
+
def supports_foreign_keys?
|
430
|
+
true
|
431
|
+
end
|
432
|
+
|
433
|
+
def supports_views?
|
434
|
+
true
|
435
|
+
end
|
427
436
|
|
428
437
|
#:stopdoc:
|
429
438
|
DEFAULT_NLS_PARAMETERS = {
|
@@ -448,11 +457,11 @@ module ActiveRecord
|
|
448
457
|
|
449
458
|
#:stopdoc:
|
450
459
|
NATIVE_DATABASE_TYPES = {
|
451
|
-
:primary_key => "NUMBER(
|
460
|
+
:primary_key => "NUMBER(38) NOT NULL PRIMARY KEY",
|
452
461
|
:string => { :name => "VARCHAR2", :limit => 255 },
|
453
462
|
:text => { :name => "CLOB" },
|
454
|
-
:integer => { :name => "NUMBER", :limit =>
|
455
|
-
:float => { :name => "
|
463
|
+
:integer => { :name => "NUMBER", :limit => 38 },
|
464
|
+
:float => { :name => "BINARY_FLOAT" },
|
456
465
|
:decimal => { :name => "DECIMAL" },
|
457
466
|
:datetime => { :name => "DATE" },
|
458
467
|
# changed to native TIMESTAMP type
|
@@ -462,7 +471,8 @@ module ActiveRecord
|
|
462
471
|
:date => { :name => "DATE" },
|
463
472
|
:binary => { :name => "BLOB" },
|
464
473
|
:boolean => { :name => "NUMBER", :limit => 1 },
|
465
|
-
:raw => { :name => "RAW", :limit => 2000 }
|
474
|
+
:raw => { :name => "RAW", :limit => 2000 },
|
475
|
+
:bigint => { :name => "NUMBER", :limit => 19 }
|
466
476
|
}
|
467
477
|
# if emulate_booleans_from_strings then store booleans in VARCHAR2
|
468
478
|
NATIVE_DATABASE_TYPES_BOOLEAN_STRINGS = NATIVE_DATABASE_TYPES.dup.merge(
|
@@ -667,22 +677,26 @@ module ActiveRecord
|
|
667
677
|
|
668
678
|
# Cast a +value+ to a type that the database understands.
|
669
679
|
def type_cast(value, column)
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
|
680
|
+
if column && column.cast_type.is_a?(Type::Serialized)
|
681
|
+
super
|
682
|
+
else
|
683
|
+
case value
|
684
|
+
when true, false
|
685
|
+
if emulate_booleans_from_strings || column && column.type == :string
|
686
|
+
self.class.boolean_to_string(value)
|
687
|
+
else
|
688
|
+
value ? 1 : 0
|
689
|
+
end
|
690
|
+
when Date, Time
|
691
|
+
if value.acts_like?(:time)
|
692
|
+
zone_conversion_method = ActiveRecord::Base.default_timezone == :utc ? :getutc : :getlocal
|
693
|
+
value.respond_to?(zone_conversion_method) ? value.send(zone_conversion_method) : value
|
694
|
+
else
|
695
|
+
value
|
696
|
+
end
|
681
697
|
else
|
682
|
-
|
698
|
+
super
|
683
699
|
end
|
684
|
-
else
|
685
|
-
super
|
686
700
|
end
|
687
701
|
end
|
688
702
|
|
@@ -812,7 +826,7 @@ module ActiveRecord
|
|
812
826
|
value = attributes[col.name]
|
813
827
|
# changed sequence of next two lines - should check if value is nil before converting to yaml
|
814
828
|
next if value.nil? || (value == '')
|
815
|
-
value = value.to_yaml if
|
829
|
+
value = value.to_yaml if value.is_a?(String) && klass.serialized_attributes[col.name]
|
816
830
|
uncached do
|
817
831
|
sql = is_with_cpk ? "SELECT #{quote_column_name(col.name)} FROM #{quote_table_name(table_name)} WHERE #{klass.composite_where_clause(id)} FOR UPDATE" :
|
818
832
|
"SELECT #{quote_column_name(col.name)} FROM #{quote_table_name(table_name)} WHERE #{quote_column_name(klass.primary_key)} = #{id} FOR UPDATE"
|
@@ -906,7 +920,7 @@ module ActiveRecord
|
|
906
920
|
statement_parameters = $1
|
907
921
|
end
|
908
922
|
end
|
909
|
-
all_schema_indexes <<
|
923
|
+
all_schema_indexes << OracleEnhanced::IndexDefinition.new(row['table_name'], row['index_name'],
|
910
924
|
row['uniqueness'] == "UNIQUE", row['index_type'] == 'DOMAIN' ? "#{row['ityp_owner']}.#{row['ityp_name']}" : nil,
|
911
925
|
row['parameters'], statement_parameters,
|
912
926
|
row['tablespace_name'] == default_tablespace_name ? nil : row['tablespace_name'], [])
|
@@ -1038,7 +1052,7 @@ module ActiveRecord
|
|
1038
1052
|
end.map do |row|
|
1039
1053
|
limit, scale = row['limit'], row['scale']
|
1040
1054
|
if limit || scale
|
1041
|
-
row['sql_type'] += "(#{(limit ||
|
1055
|
+
row['sql_type'] += "(#{(limit || 38).to_i}" + ((scale = scale.to_i) > 0 ? ",#{scale})" : ")")
|
1042
1056
|
end
|
1043
1057
|
|
1044
1058
|
if row['sql_type_owner']
|
@@ -1055,19 +1069,61 @@ module ActiveRecord
|
|
1055
1069
|
# match newlines.
|
1056
1070
|
row['data_default'].sub!(/^'(.*)'$/m, '\1')
|
1057
1071
|
row['data_default'] = nil if row['data_default'] =~ /^(null|empty_[bc]lob\(\))$/i
|
1072
|
+
# TODO: Needs better fix to fallback "N" to false
|
1073
|
+
row['data_default'] = false if row['data_default'] == "N"
|
1074
|
+
end
|
1075
|
+
|
1076
|
+
# TODO: Consider to extract another method such as `get_cast_type`
|
1077
|
+
case row['sql_type']
|
1078
|
+
when /decimal|numeric|number/i
|
1079
|
+
if get_type_for_column(table_name, oracle_downcase(row['name'])) == :integer
|
1080
|
+
cast_type = ActiveRecord::OracleEnhanced::Type::Integer.new
|
1081
|
+
elsif OracleEnhancedAdapter.emulate_booleans && row['sql_type'].upcase == "NUMBER(1)"
|
1082
|
+
cast_type = Type::Boolean.new
|
1083
|
+
elsif OracleEnhancedAdapter.emulate_integers_by_column_name && OracleEnhancedAdapter.is_integer_column?(row['name'], table_name)
|
1084
|
+
cast_type = ActiveRecord::OracleEnhanced::Type::Integer.new
|
1085
|
+
else
|
1086
|
+
cast_type = lookup_cast_type(row['sql_type'])
|
1087
|
+
end
|
1088
|
+
when /char/i
|
1089
|
+
if get_type_for_column(table_name, oracle_downcase(row['name'])) == :string
|
1090
|
+
cast_type = Type::String.new
|
1091
|
+
elsif get_type_for_column(table_name, oracle_downcase(row['name'])) == :boolean
|
1092
|
+
cast_type = Type::Boolean.new
|
1093
|
+
elsif OracleEnhancedAdapter.emulate_booleans_from_strings && OracleEnhancedAdapter.is_boolean_column?(row['name'], row['sql_type'], table_name)
|
1094
|
+
cast_type = Type::Boolean.new
|
1095
|
+
else
|
1096
|
+
cast_type = lookup_cast_type(row['sql_type'])
|
1097
|
+
end
|
1098
|
+
when /date/i
|
1099
|
+
if get_type_for_column(table_name, oracle_downcase(row['name'])) == :date
|
1100
|
+
cast_type = Type::Date.new
|
1101
|
+
elsif get_type_for_column(table_name, oracle_downcase(row['name'])) == :datetime
|
1102
|
+
cast_type = Type::DateTime.new
|
1103
|
+
elsif OracleEnhancedAdapter.emulate_dates_by_column_name && OracleEnhancedAdapter.is_date_column?(row['name'], table_name)
|
1104
|
+
cast_type = Type::Date.new
|
1105
|
+
else
|
1106
|
+
cast_type = lookup_cast_type(row['sql_type'])
|
1107
|
+
end
|
1108
|
+
else
|
1109
|
+
cast_type = lookup_cast_type(row['sql_type'])
|
1058
1110
|
end
|
1059
1111
|
|
1060
|
-
|
1112
|
+
new_column(oracle_downcase(row['name']),
|
1061
1113
|
row['data_default'],
|
1114
|
+
cast_type,
|
1062
1115
|
row['sql_type'],
|
1063
1116
|
row['nullable'] == 'Y',
|
1064
|
-
# pass table name for table specific column definitions
|
1065
1117
|
table_name,
|
1066
|
-
|
1067
|
-
|
1118
|
+
is_virtual,
|
1119
|
+
false )
|
1068
1120
|
end
|
1069
1121
|
end
|
1070
1122
|
|
1123
|
+
def new_column(name, default, cast_type, sql_type = nil, null = true, table_name = nil, virtual=false, returning_id=false)
|
1124
|
+
OracleEnhancedColumn.new(name, default, cast_type, sql_type, null, table_name, virtual, returning_id)
|
1125
|
+
end
|
1126
|
+
|
1071
1127
|
# used just in tests to clear column cache
|
1072
1128
|
def clear_columns_cache #:nodoc:
|
1073
1129
|
@@columns_cache = nil
|
@@ -1207,6 +1263,34 @@ module ActiveRecord
|
|
1207
1263
|
|
1208
1264
|
protected
|
1209
1265
|
|
1266
|
+
def initialize_type_map(m)
|
1267
|
+
super
|
1268
|
+
# oracle
|
1269
|
+
register_class_with_limit m, %r(date)i, Type::DateTime
|
1270
|
+
register_class_with_limit m, %r(raw)i, ActiveRecord::OracleEnhanced::Type::Raw
|
1271
|
+
register_class_with_limit m, %r(timestamp)i, ActiveRecord::OracleEnhanced::Type::Timestamp
|
1272
|
+
|
1273
|
+
m.register_type(%r(NUMBER)i) do |sql_type|
|
1274
|
+
scale = extract_scale(sql_type)
|
1275
|
+
precision = extract_precision(sql_type)
|
1276
|
+
limit = extract_limit(sql_type)
|
1277
|
+
if scale == 0
|
1278
|
+
ActiveRecord::OracleEnhanced::Type::Integer.new(precision: precision, limit: limit)
|
1279
|
+
else
|
1280
|
+
Type::Decimal.new(precision: precision, scale: scale)
|
1281
|
+
end
|
1282
|
+
end
|
1283
|
+
end
|
1284
|
+
|
1285
|
+
def extract_limit(sql_type) #:nodoc:
|
1286
|
+
case sql_type
|
1287
|
+
when /^bigint/i
|
1288
|
+
19
|
1289
|
+
when /\((.*)\)/
|
1290
|
+
$1.to_i
|
1291
|
+
end
|
1292
|
+
end
|
1293
|
+
|
1210
1294
|
def translate_exception(exception, message) #:nodoc:
|
1211
1295
|
case @connection.error_code(exception)
|
1212
1296
|
when 1
|
@@ -1220,6 +1304,10 @@ module ActiveRecord
|
|
1220
1304
|
|
1221
1305
|
private
|
1222
1306
|
|
1307
|
+
def select(sql, name = nil, binds = [])
|
1308
|
+
exec_query(sql, name, binds)
|
1309
|
+
end
|
1310
|
+
|
1223
1311
|
def oracle_downcase(column_name)
|
1224
1312
|
@connection.oracle_downcase(column_name)
|
1225
1313
|
end
|
@@ -1256,12 +1344,8 @@ module ActiveRecord
|
|
1256
1344
|
end
|
1257
1345
|
|
1258
1346
|
protected
|
1259
|
-
def log(sql, name, binds = nil) #:nodoc:
|
1260
|
-
|
1261
|
-
super sql, name, binds
|
1262
|
-
else
|
1263
|
-
super sql, name
|
1264
|
-
end
|
1347
|
+
def log(sql, name = "SQL", binds = [], statement_name = nil) #:nodoc:
|
1348
|
+
super
|
1265
1349
|
ensure
|
1266
1350
|
log_dbms_output if dbms_output_enabled?
|
1267
1351
|
end
|
@@ -1289,38 +1373,47 @@ module ActiveRecord
|
|
1289
1373
|
end
|
1290
1374
|
|
1291
1375
|
# Implementation of standard schema definition statements and extensions for schema definition
|
1292
|
-
require 'active_record/connection_adapters/
|
1293
|
-
require 'active_record/connection_adapters/
|
1376
|
+
require 'active_record/connection_adapters/oracle_enhanced/schema_statements'
|
1377
|
+
require 'active_record/connection_adapters/oracle_enhanced/schema_statements_ext'
|
1294
1378
|
|
1295
1379
|
# Extensions for schema definition
|
1296
|
-
require 'active_record/connection_adapters/
|
1380
|
+
require 'active_record/connection_adapters/oracle_enhanced/schema_definitions'
|
1297
1381
|
|
1298
1382
|
# Extensions for context index definition
|
1299
|
-
require 'active_record/connection_adapters/
|
1383
|
+
require 'active_record/connection_adapters/oracle_enhanced/context_index'
|
1300
1384
|
|
1301
1385
|
# Load additional methods for composite_primary_keys support
|
1302
|
-
require 'active_record/connection_adapters/
|
1386
|
+
require 'active_record/connection_adapters/oracle_enhanced/cpk'
|
1303
1387
|
|
1304
1388
|
# Load patch for dirty tracking methods
|
1305
|
-
require 'active_record/connection_adapters/
|
1389
|
+
require 'active_record/connection_adapters/oracle_enhanced/dirty'
|
1306
1390
|
|
1307
1391
|
# Patches and enhancements for schema dumper
|
1308
|
-
require 'active_record/connection_adapters/
|
1392
|
+
require 'active_record/connection_adapters/oracle_enhanced/schema_dumper'
|
1309
1393
|
|
1310
1394
|
# Implementation of structure dump
|
1311
|
-
require 'active_record/connection_adapters/
|
1395
|
+
require 'active_record/connection_adapters/oracle_enhanced/structure_dump'
|
1312
1396
|
|
1313
|
-
require 'active_record/connection_adapters/
|
1397
|
+
require 'active_record/connection_adapters/oracle_enhanced/version'
|
1314
1398
|
|
1315
1399
|
module ActiveRecord
|
1316
|
-
autoload :OracleEnhancedProcedures, 'active_record/connection_adapters/
|
1400
|
+
autoload :OracleEnhancedProcedures, 'active_record/connection_adapters/oracle_enhanced/procedures'
|
1317
1401
|
end
|
1318
1402
|
|
1319
1403
|
# Patches and enhancements for column dumper
|
1320
|
-
require 'active_record/connection_adapters/
|
1404
|
+
require 'active_record/connection_adapters/oracle_enhanced/column_dumper'
|
1321
1405
|
|
1322
1406
|
# Moved SchemaCreation class
|
1323
|
-
require 'active_record/connection_adapters/
|
1407
|
+
require 'active_record/connection_adapters/oracle_enhanced/schema_creation'
|
1324
1408
|
|
1325
1409
|
# Moved DatabaseStetements
|
1326
|
-
require 'active_record/connection_adapters/
|
1410
|
+
require 'active_record/connection_adapters/oracle_enhanced/database_statements'
|
1411
|
+
|
1412
|
+
# Add Type:Raw
|
1413
|
+
require 'active_record/oracle_enhanced/type/raw'
|
1414
|
+
|
1415
|
+
# Add Type:Timestamp
|
1416
|
+
require 'active_record/oracle_enhanced/type/timestamp'
|
1417
|
+
|
1418
|
+
# Add OracleEnhanced::Type::Integer
|
1419
|
+
require 'active_record/oracle_enhanced/type/integer'
|
@@ -5,7 +5,7 @@ if defined?(::Rails::Railtie)
|
|
5
5
|
module ConnectionAdapters
|
6
6
|
class OracleEnhancedRailtie < ::Rails::Railtie
|
7
7
|
rake_tasks do
|
8
|
-
load 'active_record/connection_adapters/
|
8
|
+
load 'active_record/connection_adapters/oracle_enhanced/database_tasks.rb'
|
9
9
|
end
|
10
10
|
|
11
11
|
ActiveSupport.on_load(:active_record) do
|
@@ -476,7 +476,7 @@ describe "OracleEnhancedAdapter" do
|
|
476
476
|
t.string :title
|
477
477
|
# cannot update LOBs over database link
|
478
478
|
t.string :body
|
479
|
-
t.timestamps
|
479
|
+
t.timestamps null: true
|
480
480
|
end
|
481
481
|
@db_link_username = SYSTEM_CONNECTION_PARAMS[:username]
|
482
482
|
@db_link_password = SYSTEM_CONNECTION_PARAMS[:password]
|
@@ -628,8 +628,8 @@ describe "OracleEnhancedAdapter" do
|
|
628
628
|
end
|
629
629
|
|
630
630
|
it "should clear older cursors when statement limit is reached" do
|
631
|
-
pk = TestPost.
|
632
|
-
sub = @conn.substitute_at(pk, 0)
|
631
|
+
pk = TestPost.columns_hash[TestPost.primary_key]
|
632
|
+
sub = @conn.substitute_at(pk, 0).to_sql
|
633
633
|
binds = [[pk, 1]]
|
634
634
|
|
635
635
|
lambda {
|
@@ -641,8 +641,8 @@ describe "OracleEnhancedAdapter" do
|
|
641
641
|
|
642
642
|
it "should cache UPDATE statements with bind variables" do
|
643
643
|
lambda {
|
644
|
-
pk = TestPost.
|
645
|
-
sub = @conn.substitute_at(pk, 0)
|
644
|
+
pk = TestPost.columns_hash[TestPost.primary_key]
|
645
|
+
sub = @conn.substitute_at(pk, 0).to_sql
|
646
646
|
binds = [[pk, 1]]
|
647
647
|
@conn.exec_update("UPDATE test_posts SET id = #{sub}", "SQL", binds)
|
648
648
|
}.should change(@statements, :length).by(+1)
|
@@ -682,36 +682,11 @@ describe "OracleEnhancedAdapter" do
|
|
682
682
|
end
|
683
683
|
|
684
684
|
it "should explain query with binds" do
|
685
|
-
pk = TestPost.
|
685
|
+
pk = TestPost.columns_hash[TestPost.primary_key]
|
686
686
|
sub = @conn.substitute_at(pk, 0)
|
687
687
|
explain = TestPost.where(TestPost.arel_table[pk.name].eq(sub)).bind([pk, 1]).explain
|
688
688
|
explain.should include("Cost")
|
689
689
|
explain.should include("INDEX UNIQUE SCAN")
|
690
690
|
end
|
691
691
|
end if ENV['RAILS_GEM_VERSION'] >= '3.2'
|
692
|
-
|
693
|
-
describe ".is_integer_column?" do
|
694
|
-
before(:all) do
|
695
|
-
@adapter = ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter
|
696
|
-
end
|
697
|
-
|
698
|
-
it "should return TrueClass or FalseClass" do
|
699
|
-
@adapter.is_integer_column?("adapter_id").should be_a TrueClass
|
700
|
-
@adapter.is_integer_column?("").should be_a FalseClass
|
701
|
-
end
|
702
|
-
|
703
|
-
it "should return true if name is 'id'" do
|
704
|
-
@adapter.is_integer_column?("id").should be_true
|
705
|
-
end
|
706
|
-
|
707
|
-
it "should return true if name ends with '_id'" do
|
708
|
-
@adapter.is_integer_column?("_id").should be_true
|
709
|
-
@adapter.is_integer_column?("foo_id").should be_true
|
710
|
-
end
|
711
|
-
|
712
|
-
it "should return false if name is 'something_else'" do
|
713
|
-
@adapter.is_integer_column?("something_else").should be_false
|
714
|
-
end
|
715
|
-
end
|
716
|
-
|
717
692
|
end
|
@@ -227,7 +227,7 @@ describe "OracleEnhancedConnection" do
|
|
227
227
|
|
228
228
|
it "should execute prepared statement with decimal bind parameter " do
|
229
229
|
cursor = @conn.prepare("INSERT INTO test_employees VALUES(:1)")
|
230
|
-
column = ActiveRecord::ConnectionAdapters::OracleEnhancedColumn.new('age', nil, 'NUMBER(10,2)')
|
230
|
+
column = ActiveRecord::ConnectionAdapters::OracleEnhancedColumn.new('age', nil, ActiveRecord::Type::Decimal.new, 'NUMBER(10,2)')
|
231
231
|
column.type.should == :decimal
|
232
232
|
cursor.bind_param(1, "1.5", column)
|
233
233
|
cursor.exec
|
@@ -11,7 +11,7 @@ describe "OracleEnhancedAdapter context index" do
|
|
11
11
|
t.string :title
|
12
12
|
t.text :body
|
13
13
|
t.integer :comments_count
|
14
|
-
t.timestamps
|
14
|
+
t.timestamps null: true
|
15
15
|
t.string :all_text, limit: 2 # will be used for multi-column index
|
16
16
|
end
|
17
17
|
end
|
@@ -23,7 +23,7 @@ describe "OracleEnhancedAdapter context index" do
|
|
23
23
|
t.integer :post_id
|
24
24
|
t.string :author
|
25
25
|
t.text :body
|
26
|
-
t.timestamps
|
26
|
+
t.timestamps null: true
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -67,12 +67,12 @@ describe "OracleEnhancedAdapter composite_primary_keys support" do
|
|
67
67
|
t.string :type_category, :limit => 15, :null => false
|
68
68
|
t.date :date_value, :null => false
|
69
69
|
t.text :results, :null => false
|
70
|
-
t.timestamps
|
70
|
+
t.timestamps null: true
|
71
71
|
end
|
72
72
|
create_table :non_cpk_write_lobs_test, :force => true do |t|
|
73
73
|
t.date :date_value, :null => false
|
74
74
|
t.text :results, :null => false
|
75
|
-
t.timestamps
|
75
|
+
t.timestamps null: true
|
76
76
|
end
|
77
77
|
end
|
78
78
|
class ::CpkWriteLobsTest < ActiveRecord::Base
|