activerecord-oracle_enhanced-adapter 1.7.7 → 1.7.8
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 +14 -0
- data/README.md +3 -0
- data/VERSION +1 -1
- data/activerecord-oracle_enhanced-adapter.gemspec +2 -3
- data/lib/active_record/connection_adapters/oracle_enhanced/column.rb +2 -6
- data/lib/active_record/connection_adapters/oracle_enhanced/column_dumper.rb +0 -2
- data/lib/active_record/connection_adapters/oracle_enhanced/connection.rb +2 -5
- data/lib/active_record/connection_adapters/oracle_enhanced/context_index.rb +0 -2
- data/lib/active_record/connection_adapters/oracle_enhanced/cpk.rb +1 -3
- data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +0 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +0 -6
- data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +0 -10
- data/lib/active_record/connection_adapters/oracle_enhanced/procedures.rb +1 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +1 -2
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +1 -5
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb +0 -2
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +10 -4
- data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements_ext.rb +0 -1
- data/lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb +4 -7
- data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +2 -6
- data/lib/active_record/oracle_enhanced/type/boolean.rb +0 -1
- data/lib/active_record/oracle_enhanced/type/integer.rb +1 -1
- data/lib/active_record/oracle_enhanced/type/national_character_string.rb +0 -1
- data/lib/active_record/oracle_enhanced/type/raw.rb +0 -1
- data/lib/active_record/oracle_enhanced/type/string.rb +0 -1
- data/lib/active_record/oracle_enhanced/type/text.rb +0 -2
- data/lib/activerecord-oracle_enhanced-adapter.rb +0 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +0 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +3 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb +4 -4
- data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +7 -8
- data/spec/active_record/connection_adapters/oracle_enhanced_database_tasks_spec.rb +0 -1
- data/spec/active_record/connection_adapters/oracle_enhanced_dbms_output_spec.rb +2 -2
- data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +3 -3
- data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +5 -5
- data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +4 -3
- data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +59 -29
- data/spec/spec_helper.rb +0 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e288f3252430d1ed219947281862797ff87b59ba
|
4
|
+
data.tar.gz: 83dc958f35386c22c8c1d7a68c1f817e4cd884cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ef95f27bd4dbaf561c5ef0f36a70903f0ed3652ca7096cfc32f7396ced16ab829717be7e79e0858ef9c7adaf79de74a805b5bad73909ea35a9f8cebb340f442
|
7
|
+
data.tar.gz: 866f47befdc34a4489b8b3da4bd35c37dfea56393a1e38e2686ccb9fe73e088f66bc7d7f26ff9ef69050d68f3b72050afd561d85f39d73f469724f4ae129cf71
|
data/History.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
## 1.7.8 / 2016-12-06
|
2
|
+
|
3
|
+
* Changes and bug fixes
|
4
|
+
* Separate schema migration insert statements correctly [#1074]
|
5
|
+
* Add `use_old_oracle_visitor` example [#1068]
|
6
|
+
* `supports_fetch_first_n_rows_and_offset?` returns `false` when `use_old_oracle_visitor` is true {1070, #1075]
|
7
|
+
* Suppress `create_table(:posts, {:force=>true})` message [#1067, #1072]
|
8
|
+
* Enable rubocop and Code Climate [#1056, #1057, #1060, #1062, #1071]
|
9
|
+
* Bump MRI version for travis [#1054, #1059]
|
10
|
+
* Drop `ActiveRecord::InternalMetadata.table_name` after each spec [#1073]
|
11
|
+
|
12
|
+
* Known issues
|
13
|
+
* No changes since 1.7.7
|
14
|
+
|
1
15
|
## 1.7.7 / 2016-11-15
|
2
16
|
|
3
17
|
* Changes and bug fixes
|
data/README.md
CHANGED
@@ -240,6 +240,9 @@ ActiveSupport.on_load(:active_record) do
|
|
240
240
|
# start primary key sequences from 1 (and not 10000) and take just one next value in each session
|
241
241
|
self.default_sequence_start_value = "1 NOCACHE INCREMENT BY 1"
|
242
242
|
|
243
|
+
# Use old visitor for Oracle 12c database
|
244
|
+
self.use_old_oracle_visitor = true
|
245
|
+
|
243
246
|
# other settings ...
|
244
247
|
end
|
245
248
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.7.
|
1
|
+
1.7.8
|
@@ -1,12 +1,12 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{activerecord-oracle_enhanced-adapter}
|
3
|
-
s.version = "1.7.
|
3
|
+
s.version = "1.7.8"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.required_ruby_version = '>= 2.2.2'
|
7
7
|
s.license = 'MIT'
|
8
8
|
s.authors = [%q{Raimonds Simanovskis}]
|
9
|
-
s.date = %q{2016-
|
9
|
+
s.date = %q{2016-12-06}
|
10
10
|
s.description = %q{Oracle "enhanced" ActiveRecord adapter contains useful additional methods for working with new and legacy Oracle databases.
|
11
11
|
This adapter is superset of original ActiveRecord Oracle adapter.
|
12
12
|
}
|
@@ -92,4 +92,3 @@ This adapter is superset of original ActiveRecord Oracle adapter.
|
|
92
92
|
s.add_runtime_dependency(%q<ruby-plsql>, [">= 0.5.0"])
|
93
93
|
s.license = 'MIT'
|
94
94
|
end
|
95
|
-
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module ActiveRecord
|
2
2
|
module ConnectionAdapters #:nodoc:
|
3
3
|
class OracleEnhancedColumn < Column
|
4
|
-
|
5
4
|
attr_reader :table_name, :nchar, :virtual_column_data_default, :returning_id #:nodoc:
|
6
5
|
|
7
6
|
def initialize(name, default, sql_type_metadata = nil, null = true, table_name = nil, virtual = false, returning_id = nil, comment = nil) #:nodoc:
|
@@ -69,7 +68,7 @@ module ActiveRecord
|
|
69
68
|
# #TODO: may be deprecated due to conflict with variable
|
70
69
|
# ActiveRecord::Base.connection.column_comment(@table_name, name)
|
71
70
|
# end
|
72
|
-
|
71
|
+
|
73
72
|
private
|
74
73
|
|
75
74
|
def self.extract_value_from_default(default)
|
@@ -85,7 +84,7 @@ module ActiveRecord
|
|
85
84
|
value.respond_to?(:hour) && (value.hour == 0 and value.min == 0 and value.sec == 0) ?
|
86
85
|
Date.new(value.year, value.month, value.day) : value
|
87
86
|
end
|
88
|
-
|
87
|
+
|
89
88
|
class << self
|
90
89
|
protected
|
91
90
|
|
@@ -128,10 +127,7 @@ module ActiveRecord
|
|
128
127
|
end
|
129
128
|
DateTime.strptime(string, OracleEnhancedAdapter.string_to_date_format).to_date
|
130
129
|
end
|
131
|
-
|
132
130
|
end
|
133
131
|
end
|
134
|
-
|
135
132
|
end
|
136
|
-
|
137
133
|
end
|
@@ -2,7 +2,6 @@ module ActiveRecord #:nodoc:
|
|
2
2
|
module ConnectionAdapters #:nodoc:
|
3
3
|
module OracleEnhanced #:nodoc:
|
4
4
|
module ColumnDumper #:nodoc:
|
5
|
-
|
6
5
|
def column_spec(column)
|
7
6
|
spec = Hash[prepare_column_options(column).map { |k, v| [k, "#{k}: #{v}"] }]
|
8
7
|
spec[:name] = column.name.inspect
|
@@ -63,7 +62,6 @@ module ActiveRecord #:nodoc:
|
|
63
62
|
column.type.inspect if column.virtual?
|
64
63
|
end
|
65
64
|
end
|
66
|
-
|
67
65
|
end
|
68
66
|
end
|
69
67
|
end
|
@@ -2,7 +2,6 @@ module ActiveRecord
|
|
2
2
|
module ConnectionAdapters
|
3
3
|
# interface independent methods
|
4
4
|
class OracleEnhancedConnection #:nodoc:
|
5
|
-
|
6
5
|
def self.create(config)
|
7
6
|
case ORACLE_ENHANCED_CONNECTION
|
8
7
|
when :oci
|
@@ -97,17 +96,15 @@ module ActiveRecord
|
|
97
96
|
result = select(sql, name = nil)
|
98
97
|
result.map { |r| r.values.first }
|
99
98
|
end
|
100
|
-
|
101
99
|
end
|
102
100
|
|
103
101
|
# Returns array with major and minor version of database (e.g. [12, 1])
|
104
102
|
def database_version
|
105
103
|
raise NoMethodError, "Not implemented for this raw driver"
|
106
|
-
end
|
107
|
-
|
108
|
-
class OracleEnhancedConnectionException < StandardError #:nodoc:
|
109
104
|
end
|
110
105
|
|
106
|
+
class OracleEnhancedConnectionException < StandardError #:nodoc:
|
107
|
+
end
|
111
108
|
end
|
112
109
|
end
|
113
110
|
|
@@ -2,7 +2,6 @@ module ActiveRecord
|
|
2
2
|
module ConnectionAdapters
|
3
3
|
module OracleEnhanced
|
4
4
|
module ContextIndex
|
5
|
-
|
6
5
|
# Define full text index with Oracle specific CONTEXT index type
|
7
6
|
#
|
8
7
|
# Oracle CONTEXT index by default supports full text indexing of one column.
|
@@ -336,7 +335,6 @@ module ActiveRecord
|
|
336
335
|
order("SCORE(#{score_label}) DESC")
|
337
336
|
end
|
338
337
|
end
|
339
|
-
|
340
338
|
end
|
341
339
|
end
|
342
340
|
end
|
@@ -1,17 +1,15 @@
|
|
1
1
|
module ActiveRecord #:nodoc:
|
2
2
|
module ConnectionAdapters #:nodoc:
|
3
3
|
module OracleEnhancedCpk #:nodoc:
|
4
|
-
|
5
4
|
# This mightn't be in Core, but count(distinct x,y) doesn't work for me.
|
6
5
|
# Return that not supported if composite_primary_keys gem is required.
|
7
6
|
def supports_count_distinct? #:nodoc:
|
8
7
|
@supports_count_distinct ||= ! defined?(CompositePrimaryKeys)
|
9
8
|
end
|
10
|
-
|
9
|
+
|
11
10
|
def concat(*columns) #:nodoc:
|
12
11
|
"(#{columns.join('||')})"
|
13
12
|
end
|
14
|
-
|
15
13
|
end
|
16
14
|
end
|
17
15
|
end
|
@@ -46,13 +46,10 @@ rescue LoadError, NameError
|
|
46
46
|
raise LoadError, "ERROR: ActiveRecord oracle_enhanced adapter could not load Oracle JDBC driver. Please install #{ojdbc_jars ? ojdbc_jars.join(' or ') : "Oracle JDBC"} library."
|
47
47
|
end
|
48
48
|
|
49
|
-
|
50
49
|
module ActiveRecord
|
51
50
|
module ConnectionAdapters
|
52
|
-
|
53
51
|
# JDBC database interface for JRuby
|
54
52
|
class OracleEnhancedJDBCConnection < OracleEnhancedConnection #:nodoc:
|
55
|
-
|
56
53
|
attr_accessor :active
|
57
54
|
alias :active? :active
|
58
55
|
|
@@ -452,7 +449,6 @@ module ActiveRecord
|
|
452
449
|
def close
|
453
450
|
@raw_statement.close
|
454
451
|
end
|
455
|
-
|
456
452
|
end
|
457
453
|
|
458
454
|
def select(sql, name = nil, return_column_names = false)
|
@@ -573,8 +569,6 @@ module ActiveRecord
|
|
573
569
|
end
|
574
570
|
end
|
575
571
|
end
|
576
|
-
|
577
572
|
end
|
578
|
-
|
579
573
|
end
|
580
574
|
end
|
@@ -18,10 +18,8 @@ end
|
|
18
18
|
|
19
19
|
module ActiveRecord
|
20
20
|
module ConnectionAdapters
|
21
|
-
|
22
21
|
# OCI database interface for MRI
|
23
22
|
class OracleEnhancedOCIConnection < OracleEnhancedConnection #:nodoc:
|
24
|
-
|
25
23
|
def initialize(config)
|
26
24
|
@raw_connection = OCI8EnhancedAutoRecover.new(config, OracleEnhancedOCIFactory)
|
27
25
|
# default schema owner
|
@@ -188,7 +186,6 @@ module ActiveRecord
|
|
188
186
|
def close
|
189
187
|
@raw_cursor.close
|
190
188
|
end
|
191
|
-
|
192
189
|
end
|
193
190
|
|
194
191
|
def select(sql, name = nil, return_column_names = false)
|
@@ -312,7 +309,6 @@ module ActiveRecord
|
|
312
309
|
::DateTime.civil(year, month, day, hour, min, sec, offset)
|
313
310
|
end
|
314
311
|
end
|
315
|
-
|
316
312
|
end
|
317
313
|
|
318
314
|
# The OracleEnhancedOCIFactory factors out the code necessary to connect and
|
@@ -369,15 +365,10 @@ module ActiveRecord
|
|
369
365
|
conn
|
370
366
|
end
|
371
367
|
end
|
372
|
-
|
373
|
-
|
374
368
|
end
|
375
369
|
end
|
376
370
|
|
377
|
-
|
378
|
-
|
379
371
|
class OCI8 #:nodoc:
|
380
|
-
|
381
372
|
def describe(name)
|
382
373
|
info = describe_table(name.to_s)
|
383
374
|
raise %Q{"DESC #{name}" failed} if info.nil?
|
@@ -463,6 +454,5 @@ class OCI8EnhancedAutoRecover < DelegateClass(OCI8) #:nodoc:
|
|
463
454
|
retry
|
464
455
|
end
|
465
456
|
end
|
466
|
-
|
467
457
|
end
|
468
458
|
#:startdoc:
|
@@ -44,7 +44,7 @@ module ActiveRecord
|
|
44
44
|
end
|
45
45
|
|
46
46
|
def default_tablespace_for(type)
|
47
|
-
(ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[type] ||
|
47
|
+
(ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[type] ||
|
48
48
|
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.default_tablespaces[native_database_types[type][:name]]) rescue nil
|
49
49
|
end
|
50
50
|
|
@@ -90,7 +90,6 @@ module ActiveRecord
|
|
90
90
|
MSG
|
91
91
|
end
|
92
92
|
end
|
93
|
-
|
94
93
|
end
|
95
94
|
end
|
96
95
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module ActiveRecord
|
2
2
|
module ConnectionAdapters
|
3
3
|
module OracleEnhanced
|
4
|
-
|
5
4
|
class ForeignKeyDefinition < ActiveRecord::ConnectionAdapters::ForeignKeyDefinition
|
6
5
|
def name
|
7
6
|
if options[:name].length > OracleEnhancedAdapter::IDENTIFIER_MAX_LENGTH
|
@@ -18,7 +17,7 @@ module ActiveRecord
|
|
18
17
|
|
19
18
|
class IndexDefinition < ActiveRecord::ConnectionAdapters::IndexDefinition
|
20
19
|
attr_accessor :parameters, :statement_parameters, :tablespace
|
21
|
-
|
20
|
+
|
22
21
|
def initialize(table, name, unique, columns, lengths, orders, where, type, using, parameters, statement_parameters, tablespace)
|
23
22
|
@parameters = parameters
|
24
23
|
@statement_parameters = statement_parameters
|
@@ -28,7 +27,6 @@ module ActiveRecord
|
|
28
27
|
end
|
29
28
|
|
30
29
|
class ColumnDefinition < ActiveRecord::ConnectionAdapters::ColumnDefinition
|
31
|
-
|
32
30
|
end
|
33
31
|
|
34
32
|
class TableDefinition < ActiveRecord::ConnectionAdapters::TableDefinition
|
@@ -65,7 +63,6 @@ module ActiveRecord
|
|
65
63
|
def create_column_definition(name, type)
|
66
64
|
OracleEnhanced::ColumnDefinition.new name, type
|
67
65
|
end
|
68
|
-
|
69
66
|
end
|
70
67
|
|
71
68
|
class AlterTable < ActiveRecord::ConnectionAdapters::AlterTable
|
@@ -86,7 +83,6 @@ module ActiveRecord
|
|
86
83
|
@base.remove_foreign_key(@name, options)
|
87
84
|
end
|
88
85
|
end
|
89
|
-
|
90
86
|
end
|
91
87
|
end
|
92
88
|
end
|
@@ -2,7 +2,6 @@ module ActiveRecord #:nodoc:
|
|
2
2
|
module ConnectionAdapters #:nodoc:
|
3
3
|
module OracleEnhanced #:nodoc:
|
4
4
|
module SchemaDumper #:nodoc:
|
5
|
-
|
6
5
|
private
|
7
6
|
|
8
7
|
def tables(stream)
|
@@ -198,7 +197,6 @@ module ActiveRecord #:nodoc:
|
|
198
197
|
end
|
199
198
|
end
|
200
199
|
end
|
201
|
-
|
202
200
|
end
|
203
201
|
end
|
204
202
|
end
|
@@ -117,6 +117,14 @@ module ActiveRecord
|
|
117
117
|
super
|
118
118
|
end
|
119
119
|
|
120
|
+
def insert_versions_sql(versions) # :nodoc:
|
121
|
+
sm_table = ActiveRecord::Migrator.schema_migrations_table_name
|
122
|
+
|
123
|
+
versions.map { |version|
|
124
|
+
"INSERT INTO #{sm_table} (version) VALUES ('#{version}')"
|
125
|
+
}.join "\n\n/\n\n"
|
126
|
+
end
|
127
|
+
|
120
128
|
def initialize_schema_migrations_table
|
121
129
|
super
|
122
130
|
end
|
@@ -366,7 +374,7 @@ module ActiveRecord
|
|
366
374
|
if options[:dependent]
|
367
375
|
ActiveSupport::Deprecation.warn "`:dependent` option will be deprecated. Please use `:on_delete` option"
|
368
376
|
end
|
369
|
-
case options[:dependent]
|
377
|
+
case options[:dependent]
|
370
378
|
when :delete then options[:on_delete] = :cascade
|
371
379
|
when :nullify then options[:on_delete] = :nullify
|
372
380
|
else
|
@@ -449,7 +457,7 @@ module ActiveRecord
|
|
449
457
|
|
450
458
|
def create_alter_table(name)
|
451
459
|
OracleEnhanced::AlterTable.new create_table_definition(name, false, {})
|
452
|
-
end
|
460
|
+
end
|
453
461
|
|
454
462
|
def tablespace_for(obj_type, tablespace_option, table_name=nil, column_name=nil)
|
455
463
|
tablespace_sql = ''
|
@@ -467,7 +475,6 @@ module ActiveRecord
|
|
467
475
|
(default_tablespaces[type] || default_tablespaces[native_database_types[type][:name]]) rescue nil
|
468
476
|
end
|
469
477
|
|
470
|
-
|
471
478
|
def column_for(table_name, column_name)
|
472
479
|
unless column = columns(table_name).find { |c| c.name == column_name.to_s }
|
473
480
|
raise "No such column: #{table_name}.#{column_name}"
|
@@ -520,7 +527,6 @@ module ActiveRecord
|
|
520
527
|
|
521
528
|
execute("ALTER INDEX #{quote_column_name(index_name)} REBUILD TABLESPACE #{tablespace}")
|
522
529
|
end
|
523
|
-
|
524
530
|
end
|
525
531
|
end
|
526
532
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module ActiveRecord #:nodoc:
|
2
2
|
module ConnectionAdapters #:nodoc:
|
3
3
|
module OracleEnhancedStructureDump #:nodoc:
|
4
|
-
|
5
4
|
# Statements separator used in structure dump to allow loading of structure dump also with SQL*Plus
|
6
5
|
STATEMENT_TOKEN = "\n\n/\n\n"
|
7
6
|
|
@@ -73,7 +72,7 @@ module ActiveRecord #:nodoc:
|
|
73
72
|
|
74
73
|
def structure_dump_primary_key(table) #:nodoc:
|
75
74
|
opts = {:name => '', :cols => []}
|
76
|
-
pks = select_all(<<-SQL, "Primary Keys")
|
75
|
+
pks = select_all(<<-SQL, "Primary Keys")
|
77
76
|
SELECT a.constraint_name, a.column_name, a.position
|
78
77
|
FROM all_cons_columns a
|
79
78
|
JOIN all_constraints c
|
@@ -92,7 +91,7 @@ module ActiveRecord #:nodoc:
|
|
92
91
|
|
93
92
|
def structure_dump_unique_keys(table) #:nodoc:
|
94
93
|
keys = {}
|
95
|
-
uks = select_all(<<-SQL, "Primary Keys")
|
94
|
+
uks = select_all(<<-SQL, "Primary Keys")
|
96
95
|
SELECT a.constraint_name, a.column_name, a.position
|
97
96
|
FROM all_cons_columns a
|
98
97
|
JOIN all_constraints c
|
@@ -191,7 +190,6 @@ module ActiveRecord #:nodoc:
|
|
191
190
|
sql
|
192
191
|
end
|
193
192
|
|
194
|
-
|
195
193
|
# Extract all stored procedures, packages, synonyms and views.
|
196
194
|
def structure_dump_db_stored_code #:nodoc:
|
197
195
|
structure = []
|
@@ -215,7 +213,7 @@ module ActiveRecord #:nodoc:
|
|
215
213
|
structure << ddl
|
216
214
|
end
|
217
215
|
|
218
|
-
# export views
|
216
|
+
# export views
|
219
217
|
select_all("SELECT view_name, text FROM all_views WHERE owner = SYS_CONTEXT('userenv', 'session_user') ORDER BY view_name ASC").each do |view|
|
220
218
|
structure << "CREATE OR REPLACE FORCE VIEW #{view['view_name']} AS\n #{view['text']}"
|
221
219
|
end
|
@@ -298,7 +296,7 @@ module ActiveRecord #:nodoc:
|
|
298
296
|
|
299
297
|
private
|
300
298
|
|
301
|
-
# virtual columns are an 11g feature. This returns [] if feature is not
|
299
|
+
# virtual columns are an 11g feature. This returns [] if feature is not
|
302
300
|
# present or none are found.
|
303
301
|
# return [{'column_name' => 'FOOS', 'data_default' => '...'}, ...]
|
304
302
|
def virtual_columns_for(table)
|
@@ -336,7 +334,6 @@ module ActiveRecord #:nodoc:
|
|
336
334
|
string << STATEMENT_TOKEN unless string.blank?
|
337
335
|
string
|
338
336
|
end
|
339
|
-
|
340
337
|
end
|
341
338
|
end
|
342
339
|
end
|
@@ -46,7 +46,6 @@ end
|
|
46
46
|
|
47
47
|
module ActiveRecord
|
48
48
|
class Base
|
49
|
-
|
50
49
|
# Specify table columns which should be ignored by ActiveRecord, e.g.:
|
51
50
|
#
|
52
51
|
# ignore_table_columns :attribute1, :attribute2
|
@@ -173,7 +172,6 @@ module ActiveRecord
|
|
173
172
|
end
|
174
173
|
|
175
174
|
module ConnectionAdapters #:nodoc:
|
176
|
-
|
177
175
|
# Oracle enhanced adapter will work with both
|
178
176
|
# Ruby 1.8/1.9 ruby-oci8 gem (which provides interface to Oracle OCI client)
|
179
177
|
# or with JRuby and Oracle JDBC driver.
|
@@ -445,7 +443,7 @@ module ActiveRecord
|
|
445
443
|
end
|
446
444
|
|
447
445
|
def arel_visitor # :nodoc:
|
448
|
-
if supports_fetch_first_n_rows_and_offset?
|
446
|
+
if supports_fetch_first_n_rows_and_offset?
|
449
447
|
Arel::Visitors::Oracle12.new(self)
|
450
448
|
else
|
451
449
|
Arel::Visitors::Oracle.new(self)
|
@@ -477,7 +475,7 @@ module ActiveRecord
|
|
477
475
|
end
|
478
476
|
|
479
477
|
def supports_fetch_first_n_rows_and_offset?
|
480
|
-
if @connection.database_version == [12,1]
|
478
|
+
if !use_old_oracle_visitor && @connection.database_version == [12,1]
|
481
479
|
true
|
482
480
|
else
|
483
481
|
false
|
@@ -767,7 +765,6 @@ module ActiveRecord
|
|
767
765
|
data_sources
|
768
766
|
end
|
769
767
|
|
770
|
-
|
771
768
|
def data_sources
|
772
769
|
select_values(
|
773
770
|
"SELECT DECODE(table_name, UPPER(table_name), LOWER(table_name), table_name) FROM all_tables WHERE owner = SYS_CONTEXT('userenv', 'current_schema') AND secondary = 'N'",
|
@@ -1306,7 +1303,6 @@ module ActiveRecord
|
|
1306
1303
|
@logger.debug "DBMS_OUTPUT: #{result[:line]}" if @logger
|
1307
1304
|
end
|
1308
1305
|
end
|
1309
|
-
|
1310
1306
|
end
|
1311
1307
|
end
|
1312
1308
|
end
|
@@ -4,7 +4,6 @@ module ActiveRecord
|
|
4
4
|
module OracleEnhanced
|
5
5
|
module Type
|
6
6
|
class Text < ActiveModel::Type::Text # :nodoc:
|
7
|
-
|
8
7
|
def changed_in_place?(raw_old_value, new_value)
|
9
8
|
#TODO: Needs to find a way not to cast here.
|
10
9
|
raw_old_value = cast(raw_old_value)
|
@@ -25,7 +24,6 @@ module ActiveRecord
|
|
25
24
|
@value
|
26
25
|
end
|
27
26
|
end
|
28
|
-
|
29
27
|
end
|
30
28
|
end
|
31
29
|
end
|
@@ -111,9 +111,11 @@ describe "OracleEnhancedConnection" do
|
|
111
111
|
end
|
112
112
|
|
113
113
|
describe "default_timezone" do
|
114
|
+
include SchemaSpecHelper
|
115
|
+
|
114
116
|
before(:all) do
|
115
117
|
ActiveRecord::Base.establish_connection(CONNECTION_WITH_TIMEZONE_PARAMS)
|
116
|
-
|
118
|
+
schema_define do
|
117
119
|
create_table :posts, :force => true do |t|
|
118
120
|
t.timestamps null: false
|
119
121
|
end
|
@@ -64,7 +64,7 @@ describe "OracleEnhancedAdapter composite_primary_keys support" do
|
|
64
64
|
before(:all) do
|
65
65
|
schema_define do
|
66
66
|
create_table :cpk_write_lobs_test, :primary_key => [:type_category, :date_value], :force => true do |t|
|
67
|
-
t.string :type_category, :limit => 15, :null => false
|
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
70
|
t.timestamps null: true
|
@@ -83,7 +83,7 @@ describe "OracleEnhancedAdapter composite_primary_keys support" do
|
|
83
83
|
set_table_name 'non_cpk_write_lobs_test'
|
84
84
|
end
|
85
85
|
end
|
86
|
-
|
86
|
+
|
87
87
|
after(:all) do
|
88
88
|
schema_define do
|
89
89
|
drop_table :cpk_write_lobs_test
|
@@ -98,14 +98,14 @@ describe "OracleEnhancedAdapter composite_primary_keys support" do
|
|
98
98
|
CpkWriteLobsTest.create(:type_category => 'AAA', :date_value => Date.today, :results => 'DATA '*10)
|
99
99
|
}.not_to raise_error
|
100
100
|
end
|
101
|
-
|
101
|
+
|
102
102
|
it "should create new record in table without CPK and with LOB" do
|
103
103
|
expect {
|
104
104
|
NonCpkWriteLobsTest.create(:date_value => Date.today, :results => 'DATA '*10)
|
105
105
|
}.not_to raise_error
|
106
106
|
end
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
# Other testing was done based on composite_primary_keys tests
|
110
110
|
|
111
111
|
end
|
@@ -171,7 +171,7 @@ describe "OracleEnhancedAdapter integer type detection based on column names" do
|
|
171
171
|
INCREMENT BY 1 START WITH 10040 CACHE 20 NOORDER NOCYCLE
|
172
172
|
SQL
|
173
173
|
end
|
174
|
-
|
174
|
+
|
175
175
|
after(:all) do
|
176
176
|
@conn.execute "DROP TABLE test2_employees"
|
177
177
|
@conn.execute "DROP SEQUENCE test2_employees_seq"
|
@@ -182,7 +182,7 @@ describe "OracleEnhancedAdapter integer type detection based on column names" do
|
|
182
182
|
class ::Test2Employee < ActiveRecord::Base
|
183
183
|
end
|
184
184
|
end
|
185
|
-
|
185
|
+
|
186
186
|
after(:each) do
|
187
187
|
Object.send(:remove_const, "Test2Employee")
|
188
188
|
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans = true
|
@@ -440,10 +440,12 @@ describe "OracleEnhancedAdapter boolean type detection based on string column ty
|
|
440
440
|
end
|
441
441
|
|
442
442
|
describe "OracleEnhancedAdapter boolean support when emulate_booleans_from_strings = true" do
|
443
|
+
include SchemaSpecHelper
|
444
|
+
|
443
445
|
before(:all) do
|
444
446
|
ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.emulate_booleans_from_strings = true
|
445
447
|
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
446
|
-
|
448
|
+
schema_define do
|
447
449
|
create_table :posts, :force => true do |t|
|
448
450
|
t.string :name, null: false
|
449
451
|
t.boolean :is_default, default: false
|
@@ -559,7 +561,6 @@ describe "OracleEnhancedAdapter timestamp with timezone support" do
|
|
559
561
|
|
560
562
|
end
|
561
563
|
|
562
|
-
|
563
564
|
describe "OracleEnhancedAdapter date and timestamp with different NLS date formats" do
|
564
565
|
before(:all) do
|
565
566
|
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
@@ -818,7 +819,7 @@ describe "OracleEnhancedAdapter assign string to :date and :datetime columns" do
|
|
818
819
|
@employee.reload
|
819
820
|
expect(@employee.last_login_at).to eq(@today.to_time)
|
820
821
|
end
|
821
|
-
|
822
|
+
|
822
823
|
end
|
823
824
|
|
824
825
|
describe "OracleEnhancedAdapter handling of CLOB columns" do
|
@@ -941,7 +942,6 @@ describe "OracleEnhancedAdapter handling of CLOB columns" do
|
|
941
942
|
expect(@employee.comments).to be_nil
|
942
943
|
end
|
943
944
|
|
944
|
-
|
945
945
|
it "should create record with CLOB data" do
|
946
946
|
@employee = TestEmployee.create!(
|
947
947
|
:first_name => "First",
|
@@ -1321,7 +1321,6 @@ describe "OracleEnhancedAdapter handling of RAW columns" do
|
|
1321
1321
|
end
|
1322
1322
|
end
|
1323
1323
|
|
1324
|
-
|
1325
1324
|
describe "OracleEnhancedAdapter quoting of NCHAR and NVARCHAR2 columns" do
|
1326
1325
|
before(:all) do
|
1327
1326
|
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
@@ -1403,7 +1402,7 @@ describe "OracleEnhancedAdapter handling of BINARY_FLOAT columns" do
|
|
1403
1402
|
INCREMENT BY 1 START WITH 10040 CACHE 20 NOORDER NOCYCLE
|
1404
1403
|
SQL
|
1405
1404
|
end
|
1406
|
-
|
1405
|
+
|
1407
1406
|
after(:all) do
|
1408
1407
|
@conn.execute "DROP TABLE test2_employees"
|
1409
1408
|
@conn.execute "DROP SEQUENCE test2_employees_seq"
|
@@ -51,7 +51,7 @@ describe "OracleEnhancedAdapter logging dbms_output from plsql" do
|
|
51
51
|
@conn.enable_dbms_output
|
52
52
|
|
53
53
|
expect(@conn.select_all("select more_than_five_characters_long('hi there') is_it_long from dual").to_a).to eq([{'is_it_long'=>1}])
|
54
|
-
|
54
|
+
|
55
55
|
expect(@logger.output(:debug)).to match(/^DBMS_OUTPUT: before the if -hi there-$/)
|
56
56
|
expect(@logger.output(:debug)).to match(/^DBMS_OUTPUT: it is longer than 5$/)
|
57
57
|
expect(@logger.output(:debug)).to match(/^DBMS_OUTPUT: about to return: 1$/)
|
@@ -61,7 +61,7 @@ describe "OracleEnhancedAdapter logging dbms_output from plsql" do
|
|
61
61
|
@conn.enable_dbms_output
|
62
62
|
|
63
63
|
expect(@conn.select_all("select more_than_five_characters_long('short') is_it_long from dual").to_a).to eq([{'is_it_long'=>0}])
|
64
|
-
|
64
|
+
|
65
65
|
expect(@logger.output(:debug)).to match(/^DBMS_OUTPUT: before the if -short-$/)
|
66
66
|
expect(@logger.output(:debug)).to match(/^DBMS_OUTPUT: it is 5 or shorter$/)
|
67
67
|
expect(@logger.output(:debug)).to match(/^DBMS_OUTPUT: about to return: 0$/)
|
@@ -27,13 +27,13 @@ if ActiveRecord::Base.method_defined?(:changed?)
|
|
27
27
|
class TestEmployee < ActiveRecord::Base
|
28
28
|
end
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
after(:all) do
|
32
32
|
Object.send(:remove_const, "TestEmployee")
|
33
33
|
@conn.execute "DROP TABLE test_employees"
|
34
34
|
@conn.execute "DROP SEQUENCE test_employees_seq"
|
35
35
|
ActiveRecord::Base.clear_cache! if ActiveRecord::Base.respond_to?(:"clear_cache!")
|
36
|
-
end
|
36
|
+
end
|
37
37
|
|
38
38
|
it "should not mark empty string (stored as NULL) as changed when reassigning it" do
|
39
39
|
@employee = TestEmployee.create!(:first_name => '')
|
@@ -111,7 +111,7 @@ if ActiveRecord::Base.method_defined?(:changed?)
|
|
111
111
|
@employee = TestEmployee.new
|
112
112
|
@employee.job_id = 0
|
113
113
|
expect(@employee.save!).to be_truthy
|
114
|
-
|
114
|
+
|
115
115
|
expect(@employee).not_to be_changed
|
116
116
|
|
117
117
|
@employee.job_id = '0'
|
@@ -4,7 +4,7 @@ require 'ruby-plsql'
|
|
4
4
|
|
5
5
|
describe "OracleEnhancedAdapter custom methods for create, update and destroy" do
|
6
6
|
include LoggerSpecHelper
|
7
|
-
|
7
|
+
|
8
8
|
before(:all) do
|
9
9
|
ActiveRecord::Base.establish_connection(CONNECTION_PARAMS)
|
10
10
|
@conn = ActiveRecord::Base.connection
|
@@ -67,7 +67,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
67
67
|
VALUES (p_employee_id, p_first_name, p_last_name, p_hire_date, p_salary, p_description,
|
68
68
|
1, SYSDATE, SYSDATE);
|
69
69
|
END create_employee;
|
70
|
-
|
70
|
+
|
71
71
|
PROCEDURE update_employee(
|
72
72
|
p_employee_id NUMBER,
|
73
73
|
p_first_name VARCHAR2,
|
@@ -85,7 +85,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
85
85
|
version = v_version + 1, update_time = SYSDATE
|
86
86
|
WHERE employee_id = p_employee_id;
|
87
87
|
END update_employee;
|
88
|
-
|
88
|
+
|
89
89
|
PROCEDURE delete_employee(
|
90
90
|
p_employee_id NUMBER)
|
91
91
|
IS
|
@@ -111,7 +111,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
111
111
|
self.primary_key = :employee_id
|
112
112
|
|
113
113
|
validates_presence_of :first_name, :last_name, :hire_date
|
114
|
-
|
114
|
+
|
115
115
|
# should return ID of new record
|
116
116
|
set_create_method do
|
117
117
|
plsql.test_employees_pkg.create_employee(
|
@@ -372,5 +372,5 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
|
|
372
372
|
expect(@employee.save).to be_falsey
|
373
373
|
expect(@employee.errors[:first_name]).not_to be_blank
|
374
374
|
end
|
375
|
-
|
375
|
+
|
376
376
|
end
|
@@ -77,6 +77,7 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
77
77
|
after(:each) do
|
78
78
|
drop_test_posts_table
|
79
79
|
@conn.drop_table(ActiveRecord::Migrator.schema_migrations_table_name) if @conn.table_exists?(ActiveRecord::Migrator.schema_migrations_table_name)
|
80
|
+
@conn.drop_table(ActiveRecord::InternalMetadata.table_name) if @conn.table_exists?(ActiveRecord::InternalMetadata.table_name)
|
80
81
|
ActiveRecord::Base.table_name_prefix = ''
|
81
82
|
ActiveRecord::Base.table_name_suffix = ''
|
82
83
|
end
|
@@ -234,7 +235,7 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
234
235
|
dump = standard_dump
|
235
236
|
expect(dump.rindex("create_table")).to be < dump.index("add_foreign_key")
|
236
237
|
end
|
237
|
-
|
238
|
+
|
238
239
|
it "should include primary_key when reference column name is not 'id'" do
|
239
240
|
schema_define do
|
240
241
|
create_table :test_posts, force: true, :primary_key => 'baz_id' do |t|
|
@@ -253,7 +254,7 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
253
254
|
|
254
255
|
expect(standard_dump).to match(/add_foreign_key "test_comments", "test_posts", column: "baz_id", primary_key: "baz_id", name: "test_comments_baz_id_fk"/)
|
255
256
|
end
|
256
|
-
|
257
|
+
|
257
258
|
end
|
258
259
|
|
259
260
|
describe "synonyms" do
|
@@ -415,7 +416,7 @@ describe "OracleEnhancedAdapter schema dump" do
|
|
415
416
|
context "with index on virtual column" do
|
416
417
|
before(:all) do
|
417
418
|
if @oracle11g_or_higher
|
418
|
-
schema_define do
|
419
|
+
schema_define do
|
419
420
|
add_index 'test_names', 'field_with_leading_space', :name => "index_on_virtual_col"
|
420
421
|
end
|
421
422
|
end
|
@@ -22,9 +22,9 @@ describe "OracleEnhancedAdapter structure dump" do
|
|
22
22
|
end
|
23
23
|
TestPost.table_name = "test_posts"
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
after(:each) do
|
27
|
-
@conn.drop_table :test_posts
|
27
|
+
@conn.drop_table :test_posts
|
28
28
|
@conn.drop_table :foos
|
29
29
|
@conn.execute "DROP SEQUENCE test_posts_seq" rescue nil
|
30
30
|
@conn.execute "ALTER TABLE test_posts drop CONSTRAINT fk_test_post_foo" rescue nil
|
@@ -40,12 +40,12 @@ describe "OracleEnhancedAdapter structure dump" do
|
|
40
40
|
@conn.execute "DROP VIEW test_posts_view_z" rescue nil
|
41
41
|
@conn.execute "DROP VIEW test_posts_view_a" rescue nil
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
it "should dump single primary key" do
|
45
45
|
dump = ActiveRecord::Base.connection.structure_dump
|
46
46
|
expect(dump).to match(/CONSTRAINT (.+) PRIMARY KEY \(ID\)\n/)
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
it "should dump composite primary keys" do
|
50
50
|
pk = @conn.send(:select_one, <<-SQL)
|
51
51
|
select constraint_name from user_constraints where table_name = 'TEST_POSTS' and constraint_type='P'
|
@@ -60,43 +60,43 @@ describe "OracleEnhancedAdapter structure dump" do
|
|
60
60
|
dump = ActiveRecord::Base.connection.structure_dump
|
61
61
|
expect(dump).to match(/CONSTRAINT (.+) PRIMARY KEY \(ID,TITLE\)\n/)
|
62
62
|
end
|
63
|
-
|
63
|
+
|
64
64
|
it "should dump foreign keys" do
|
65
65
|
@conn.execute <<-SQL
|
66
|
-
ALTER TABLE TEST_POSTS
|
66
|
+
ALTER TABLE TEST_POSTS
|
67
67
|
ADD CONSTRAINT fk_test_post_foo FOREIGN KEY (foo_id) REFERENCES foos(id)
|
68
68
|
SQL
|
69
69
|
dump = ActiveRecord::Base.connection.structure_dump_fk_constraints
|
70
70
|
expect(dump.split('\n').length).to eq(1)
|
71
71
|
expect(dump).to match(/ALTER TABLE \"?TEST_POSTS\"? ADD CONSTRAINT \"?FK_TEST_POST_FOO\"? FOREIGN KEY \(\"?FOO_ID\"?\) REFERENCES \"?FOOS\"?\(\"?ID\"?\)/i)
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
it "should dump foreign keys when reference column name is not 'id'" do
|
75
75
|
@conn.add_column :foos, :baz_id, :integer
|
76
|
-
|
76
|
+
|
77
77
|
@conn.execute <<-SQL
|
78
|
-
ALTER TABLE FOOS
|
78
|
+
ALTER TABLE FOOS
|
79
79
|
ADD CONSTRAINT UK_BAZ UNIQUE (BAZ_ID)
|
80
80
|
SQL
|
81
|
-
|
81
|
+
|
82
82
|
@conn.add_column :test_posts, :baz_id, :integer
|
83
|
-
|
83
|
+
|
84
84
|
@conn.execute <<-SQL
|
85
|
-
ALTER TABLE TEST_POSTS
|
85
|
+
ALTER TABLE TEST_POSTS
|
86
86
|
ADD CONSTRAINT fk_test_post_baz FOREIGN KEY (baz_id) REFERENCES foos(baz_id)
|
87
87
|
SQL
|
88
|
-
|
88
|
+
|
89
89
|
dump = ActiveRecord::Base.connection.structure_dump_fk_constraints
|
90
90
|
expect(dump.split('\n').length).to eq(1)
|
91
91
|
expect(dump).to match(/ALTER TABLE \"?TEST_POSTS\"? ADD CONSTRAINT \"?FK_TEST_POST_BAZ\"? FOREIGN KEY \(\"?BAZ_ID\"?\) REFERENCES \"?FOOS\"?\(\"?BAZ_ID\"?\)/i)
|
92
92
|
end
|
93
|
-
|
93
|
+
|
94
94
|
it "should not error when no foreign keys are present" do
|
95
95
|
dump = ActiveRecord::Base.connection.structure_dump_fk_constraints
|
96
96
|
expect(dump.split('\n').length).to eq(0)
|
97
97
|
expect(dump).to eq('')
|
98
98
|
end
|
99
|
-
|
99
|
+
|
100
100
|
it "should dump triggers" do
|
101
101
|
@conn.execute <<-SQL
|
102
102
|
create or replace TRIGGER TEST_POST_TRIGGER
|
@@ -110,7 +110,7 @@ describe "OracleEnhancedAdapter structure dump" do
|
|
110
110
|
dump = ActiveRecord::Base.connection.structure_dump_db_stored_code.gsub(/\n|\s+/,' ')
|
111
111
|
expect(dump).to match(/CREATE OR REPLACE TRIGGER TEST_POST_TRIGGER/)
|
112
112
|
end
|
113
|
-
|
113
|
+
|
114
114
|
it "should dump types" do
|
115
115
|
@conn.execute <<-SQL
|
116
116
|
create or replace TYPE TEST_TYPE AS TABLE OF VARCHAR2(10);
|
@@ -125,7 +125,7 @@ describe "OracleEnhancedAdapter structure dump" do
|
|
125
125
|
dump = ActiveRecord::Base.connection.structure_dump_db_stored_code.gsub(/\n|\s+/,' ')
|
126
126
|
expect(dump).to match(/CREATE OR REPLACE FORCE VIEW TEST_POSTS_VIEW_A.*CREATE OR REPLACE FORCE VIEW TEST_POSTS_VIEW_Z/)
|
127
127
|
end
|
128
|
-
|
128
|
+
|
129
129
|
it "should dump virtual columns" do
|
130
130
|
skip "Not supported in this database version" unless @oracle11g_or_higher
|
131
131
|
@conn.execute <<-SQL
|
@@ -159,20 +159,20 @@ describe "OracleEnhancedAdapter structure dump" do
|
|
159
159
|
SQL
|
160
160
|
dump = ActiveRecord::Base.connection.structure_dump_unique_keys("test_posts")
|
161
161
|
expect(dump).to eq(["ALTER TABLE TEST_POSTS ADD CONSTRAINT UK_FOO_FOO_ID UNIQUE (FOO,FOO_ID)"])
|
162
|
-
|
162
|
+
|
163
163
|
dump = ActiveRecord::Base.connection.structure_dump
|
164
164
|
expect(dump).to match(/CONSTRAINT UK_FOO_FOO_ID UNIQUE \(FOO,FOO_ID\)/)
|
165
165
|
end
|
166
|
-
|
166
|
+
|
167
167
|
it "should dump indexes" do
|
168
168
|
ActiveRecord::Base.connection.add_index(:test_posts, :foo, :name => :ix_test_posts_foo)
|
169
169
|
ActiveRecord::Base.connection.add_index(:test_posts, :foo_id, :name => :ix_test_posts_foo_id, :unique => true)
|
170
|
-
|
170
|
+
|
171
171
|
@conn.execute <<-SQL
|
172
172
|
ALTER TABLE test_posts
|
173
173
|
add CONSTRAINT uk_foo_foo_id UNIQUE (foo, foo_id)
|
174
174
|
SQL
|
175
|
-
|
175
|
+
|
176
176
|
dump = ActiveRecord::Base.connection.structure_dump
|
177
177
|
expect(dump).to match(/CREATE UNIQUE INDEX "?IX_TEST_POSTS_FOO_ID"? ON "?TEST_POSTS"? \("?FOO_ID"?\)/i)
|
178
178
|
expect(dump).to match(/CREATE INDEX "?IX_TEST_POSTS_FOO\"? ON "?TEST_POSTS"? \("?FOO"?\)/i)
|
@@ -260,11 +260,11 @@ describe "OracleEnhancedAdapter structure dump" do
|
|
260
260
|
|
261
261
|
it "should return the character size of nvarchar fields" do
|
262
262
|
if /.*unq_nvarchar nvarchar2\((\d+)\).*/ =~ @conn.structure_dump
|
263
|
-
|
263
|
+
expect("#$1").to eq("255")
|
264
264
|
end
|
265
265
|
end
|
266
266
|
end
|
267
|
-
|
267
|
+
|
268
268
|
describe "temp_table_drop" do
|
269
269
|
before(:each) do
|
270
270
|
@conn.create_table :temp_tbl, :temporary => true do |t|
|
@@ -280,13 +280,43 @@ describe "OracleEnhancedAdapter structure dump" do
|
|
280
280
|
expect(dump).not_to match(/DROP TABLE "?NOT_TEMP_TBL"?/i)
|
281
281
|
end
|
282
282
|
after(:each) do
|
283
|
-
@conn.drop_table :temp_tbl
|
283
|
+
@conn.drop_table :temp_tbl
|
284
284
|
@conn.drop_table :not_temp_tbl
|
285
285
|
end
|
286
286
|
end
|
287
|
-
|
287
|
+
|
288
|
+
describe "schema migrations" do
|
289
|
+
let(:versions) do
|
290
|
+
(1..10).map do |i|
|
291
|
+
Time.parse("2016.01.#{i}").strftime("%Y%m%d%H%M%S")
|
292
|
+
end
|
293
|
+
end
|
294
|
+
before do
|
295
|
+
ActiveRecord::SchemaMigration.reset_table_name
|
296
|
+
ActiveRecord::SchemaMigration.create_table
|
297
|
+
versions.each do |i|
|
298
|
+
ActiveRecord::SchemaMigration.create!(:version => i)
|
299
|
+
end
|
300
|
+
end
|
301
|
+
let(:dump) { ActiveRecord::Base.connection.dump_schema_information }
|
302
|
+
it "should dump schema migrations one version per insert" do
|
303
|
+
versions[0...-1].each do |i|
|
304
|
+
expect(dump).to include "INSERT INTO schema_migrations (version) VALUES ('#{i}')\n\n/\n"
|
305
|
+
end
|
306
|
+
end
|
307
|
+
it "should not add own separator or newline" do
|
308
|
+
expect(dump).to match(/INSERT INTO schema_migrations \(version\) VALUES \('#{versions.last}'\)\z/)
|
309
|
+
end
|
310
|
+
it "should contain expected amount of lines" do
|
311
|
+
expect(dump.lines.length).to eq(4 * (versions.length - 1) + 1)
|
312
|
+
end
|
313
|
+
after do
|
314
|
+
ActiveRecord::SchemaMigration.drop_table
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
288
318
|
describe "full drop" do
|
289
|
-
before(:each) do
|
319
|
+
before(:each) do
|
290
320
|
@conn.create_table :full_drop_test do |t|
|
291
321
|
t.string :foo
|
292
322
|
end
|
@@ -308,7 +338,7 @@ describe "OracleEnhancedAdapter structure dump" do
|
|
308
338
|
end test_package;
|
309
339
|
SQL
|
310
340
|
@conn.execute <<-SQL
|
311
|
-
create or replace package body full_drop_test_package as
|
341
|
+
create or replace package body full_drop_test_package as
|
312
342
|
function test_func return varchar2 is
|
313
343
|
begin
|
314
344
|
return ('foo');
|
@@ -318,10 +348,10 @@ describe "OracleEnhancedAdapter structure dump" do
|
|
318
348
|
#function
|
319
349
|
@conn.execute <<-SQL
|
320
350
|
create or replace function full_drop_test_function
|
321
|
-
return varchar2
|
351
|
+
return varchar2
|
322
352
|
is
|
323
353
|
foo varchar2(3);
|
324
|
-
begin
|
354
|
+
begin
|
325
355
|
return('foo');
|
326
356
|
end;
|
327
357
|
SQL
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-oracle_enhanced-adapter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.7.
|
4
|
+
version: 1.7.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Raimonds Simanovskis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
133
|
version: '0'
|
134
134
|
requirements: []
|
135
135
|
rubyforge_project:
|
136
|
-
rubygems_version: 2.
|
136
|
+
rubygems_version: 2.6.8
|
137
137
|
signing_key:
|
138
138
|
specification_version: 4
|
139
139
|
summary: Oracle enhanced adapter for ActiveRecord
|