activerecord-oracle_enhanced-adapter 1.7.11 → 1.8.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/History.md +206 -4
  3. data/README.md +37 -1
  4. data/VERSION +1 -1
  5. data/lib/active_record/connection_adapters/emulation/oracle_adapter.rb +1 -1
  6. data/lib/active_record/connection_adapters/oracle_enhanced/column.rb +7 -59
  7. data/lib/active_record/connection_adapters/oracle_enhanced/column_dumper.rb +6 -50
  8. data/lib/active_record/connection_adapters/oracle_enhanced/connection.rb +11 -11
  9. data/lib/active_record/connection_adapters/oracle_enhanced/context_index.rb +117 -117
  10. data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +37 -27
  11. data/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb +10 -10
  12. data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +56 -71
  13. data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb +0 -7
  14. data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +51 -69
  15. data/lib/active_record/connection_adapters/oracle_enhanced/oci_quoting.rb +4 -4
  16. data/lib/active_record/connection_adapters/oracle_enhanced/procedures.rb +76 -76
  17. data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +14 -43
  18. data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +60 -64
  19. data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +33 -47
  20. data/lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb +150 -160
  21. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +95 -133
  22. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements_ext.rb +3 -3
  23. data/lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb +66 -101
  24. data/lib/active_record/connection_adapters/oracle_enhanced/version.rb +1 -1
  25. data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +290 -533
  26. data/lib/active_record/oracle_enhanced/type/boolean.rb +7 -10
  27. data/lib/active_record/oracle_enhanced/type/integer.rb +3 -4
  28. data/lib/active_record/oracle_enhanced/type/json.rb +8 -0
  29. data/lib/active_record/oracle_enhanced/type/national_character_string.rb +1 -1
  30. data/lib/active_record/oracle_enhanced/type/raw.rb +2 -3
  31. data/lib/active_record/oracle_enhanced/type/string.rb +2 -2
  32. data/lib/active_record/oracle_enhanced/type/text.rb +2 -2
  33. data/lib/active_record/oracle_enhanced/type/timestamptz.rb +23 -0
  34. data/lib/activerecord-oracle_enhanced-adapter.rb +2 -2
  35. data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +55 -162
  36. data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +32 -34
  37. data/spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb +44 -42
  38. data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +250 -357
  39. data/spec/active_record/connection_adapters/oracle_enhanced_database_tasks_spec.rb +14 -6
  40. data/spec/active_record/connection_adapters/oracle_enhanced_dbms_output_spec.rb +3 -5
  41. data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +115 -124
  42. data/spec/active_record/connection_adapters/oracle_enhanced_emulate_oracle_adapter_spec.rb +2 -3
  43. data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +68 -72
  44. data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +64 -80
  45. data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +223 -329
  46. data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +18 -20
  47. data/spec/spec_config.yaml.template +11 -0
  48. data/spec/spec_helper.rb +59 -59
  49. data/spec/support/alter_system_user_password.sql +2 -0
  50. data/spec/support/create_oracle_enhanced_users.sql +31 -0
  51. metadata +25 -25
  52. data/.rspec +0 -2
  53. data/Gemfile +0 -22
  54. data/RUNNING_TESTS.md +0 -83
  55. data/Rakefile +0 -45
  56. data/activerecord-oracle_enhanced-adapter.gemspec +0 -94
  57. data/lib/active_record/connection_adapters/oracle_enhanced/cpk.rb +0 -19
  58. data/spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb +0 -113
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ecf7fafba601af5f9f8fb575e5b969d3a182b7ea
4
- data.tar.gz: 2f4e070cb162a4be21eb45dc747603683ef0c0bb
3
+ metadata.gz: 955c1c3d11ce8928038c4f64681234c4cf7ad304
4
+ data.tar.gz: c08040c3b024d62a76653409df2cda7e723a7ce6
5
5
  SHA512:
6
- metadata.gz: 5357a8e895491e97b631594d594ec3c37c73a4a983864780df23ff7f906bd26dd8b916c94b986fdff881c17729b63abc0c230dbeea38ca8df725e0b8ea645ee2
7
- data.tar.gz: f1081e23da7dc9423c85c083de163841bd73c56e77c496e87d65ad970ceb927076e0e5884aad2412315cc0ea66c4a261e3047153be4ef8bd0e7933081655e4b7
6
+ metadata.gz: 758ddc44a6c42afe6a160142c5d6d489bb5c4f240333d1ce715e7434f4da57240a46f84207b1160fe831bd0489a76e23e21cea4515b159bc01ade69379cc1620
7
+ data.tar.gz: a95939add8ff9aebaf535aeb4d293f0466dcde14479e0ccf4fdbdcf54f37b23e34924f793b54975dc06e0e0e24ec24406b441a6106a071946f7dcf25bd4fb04c
data/History.md CHANGED
@@ -1,11 +1,213 @@
1
- ## 1.7.11 / 2017-03-29
1
+ ## 1.8.2 / 2017-08-24
2
2
 
3
3
  * Changes and bug fixes
4
- * Bump JRuby to 9.1.8.0 and add JRUBY_OPTS [#1233]
5
- * Fix the BINARY_FLOAT column type returns nil in JRuby [#1256]
4
+ * Fix cursor leak when using activerecord-import gem [#1409, #1433]
5
+ * Mention new statement_limit default [#1364, #1365]
6
+ * Add upgrade section for `:statement_limit` value at Rails 5.1 [#1362, #1363]
7
+ * Set `disk_asynch_io` to `false` [#1413, #1414]
8
+ * Update README.md [#1367 #1368]
9
+ * CI against JRuby 9.1.12.0 [#1359, #1360]
10
+ * Bump ruby versions [#1346]
11
+ * rubocop namespace changes from `Style` to `Layout` [#1347, #1351]
12
+
13
+ * Changes and bug fixes
14
+ * No changes since 1.8.0.rc3
15
+
16
+ ## 1.8.1 / 2017-05-11
17
+
18
+ * Changes and bug fixes
19
+ * Address `undefined method `tablespace' for #<ActiveRecord::ConnectionAdapters::IndexDefinition [#1332, #1334, #1336]
20
+ * Rails 5.1.0.rcX is not supported anymore [#1311]
21
+ * Use Ubuntu 12.04 at Travis [#1324]
22
+
23
+ ## 1.8.0 / 2017-04-27
24
+
25
+ * Major enhancements
26
+ * Support Rails 5.1.0
27
+ * Add JSON attribute support [#1240]
28
+ * Update `database.yml` when `rails new <new_app> -d oracle` specified [rails/rails#28257]
29
+
30
+ * Changes and bug fixes
31
+ * No changes since 1.8.0.rc3
32
+
33
+ ## 1.8.0.rc3 / 2017-04-24
34
+
35
+ * Changes and bug fixes
36
+ * Include VERSION file in gem [#1302, #1303]
37
+
38
+ ## 1.8.0.rc2 / 2017-04-19
39
+
40
+ * Changes and bug fixes
41
+ * Fix `select_all` with legacy `binds` [#1246,#1248,#1250]
42
+ * Fix the `BINARY_FLOAT` column type returns nil in JRuby [#1244, #1254, #1255]
43
+ * Handle `TIMESTAMP WITH TIMEZONE` separately from `TIMEZONE` [#1206, #1267, #1268]
44
+ * Changing `NLS_DATE_FORMAT` and `NLS_TIMESTAMP_FORMAT` is not supported [#1267, #1268]
45
+ * Let abstract adapter type cast Date, DateTime and Time for JRuby [#1272, #1273]
46
+ * Collapse a file specification in gemspec [#1296, #1297]
47
+ * Do not write VERSION directly with gemspec [#1298, #1299]
48
+ * Omit specification of release date in gemspec [#1298, #1299]
49
+ * Add missing `timestamptz.rb` to gemspec at release18 branch [#1286]
50
+ * Remove specs for unsupported behaviour which causes `ORA-01861` [#1267, #1269, #1271]
51
+ * Address `OCIException: OCI8 was already closed` at specs for JSON [#1265, #1266]
52
+ * Bump Ruby version to 2.2.7 [#1261]
53
+
54
+ ## 1.8.0.rc1 / 2017-03-20
55
+
56
+ * Major enhancements
57
+ * Support Rails 5.1.0.rc1
58
+ * Add JSON attribute support #1240
59
+ * Update `database.yml` when `rails new <new_app> -d oracle` specified [rails/rails#28257]
60
+
61
+ * Changes and bug fixes
62
+ * Eliminate a redundant empty lines in schema.rb generated by SchemaDumper [#1232]
63
+ * Align the columns of db/structure.sql [#1242]
64
+ * Use Abstract StatementPool (new `statement_limit` default is 1000 was 250) [#1228]
65
+ * Decouple Composite Primary Key code [#1224, #1225]
66
+ * Push `valid_type?` up to abstract adapter [#1208]
67
+ * Oracle12 visitor is also available for 12.2 [#1217]
68
+ * Oracle Database 12c Release 2 bundles new ojdbc8.jar [#1218]
69
+ * Deprecate `supports_migrations?` on connection adapters [#1209]
70
+ * Use `ActiveRecord::SchemaMigration.table_name` [#1221]
71
+ * No need to check if `changed?` defined [#1226]
72
+ * No need to initialize `@quoted_column_names` and `@quoted_table_names` [#1227]
73
+ * Hard code `empty_blob()` or `empty_clob()` based on types [#1229]
74
+ * ruby-plsql 0.6.0 or higher version is required [#1216]
75
+ * No need to specify `rack` in Gemfile [#1230]
76
+ * Bundle from more secure source [#1243]
77
+ * Add Travis CI build status [#1231]
78
+ * Bump JRuby to 9.1.8.0 [#1222]
79
+ * Remove a duplicate spec testing `Model.distinct.count` [#1235]
80
+ * Suppress unused and not initialized warnings [#1215]
81
+ * Suppress `WARNING: Using the `raise_error` matcher without providing a specific error` [#1219]
82
+ * Suppress `WARNING: Using `expect { }.not_to raise_error(...)` risks false positives` [#1220]
83
+
84
+ ## 1.8.0.beta1 / 2017-02-27
85
+
86
+ * Major enhancements
87
+ * Support Rails 5.1.0.beta1
88
+ * Fallback :bigint to :integer for primary keys [#1077]
89
+ * Drop Java SE 6 or older version of Java SE support [#1126]
90
+ * Drop JRuby 9.0.x support for Rails 5.1 [#1147]
91
+ * Refactor ColumnDumper to support consistent Virtual column with Rails [#1185]
92
+ * Schema dumper supports `t.index` in `create_table` [#1187]
93
+ * `table_exists?` only checks tables, does not check views [#1179, #1191]
94
+ * `data_sources` returns tables and views [#1192]
95
+ * `Model.table_comment` syntax is not supported anymore [#1199]
96
+ * Remove Oracle enhanced adapter own foreign key implementations [#977]
97
+
98
+ * Changes and bug fixes
99
+ * Rails 5.1.0.beta1 is out [#1204]
100
+ * Composite foreign keys are not supported [#1188]
101
+ * Introduce `supports_virtual_columns?` [#1184]
102
+ * Made it able to change column with adding comment [#1156, #1164]
103
+ * Omit table comment option of schema.rb if it is blank [#1159]
104
+ * Fix to return nil if column comment is blank at table creation [#1158]
105
+ * `bind_param` arity change, not to take column [#1203]
106
+ * ActiveRecord `structure_dump` and `structure_load` signature changes [#1125]
107
+ * Quoting booleans should return a frozen string [#956]
108
+ * Pass `type_casted_binds` to log subscriber [#957]
109
+ * `supports_datetime_with_precision?` always returns `true` [#964]
110
+ * Handle ORA-00942 and ORA-00955 as `ActiveRecord::StatementInvalid` [#1093]
111
+ * Raise `ActiveRecord::StatementInvalid` at `rename_index` when old index does not exist [#1195]
112
+ * Handle `ORA-01418: specified index does not exist` as `ActiveRecord::StatementInvalid` [#1195]
113
+ * Raise ActiveRecord::NotNullViolation when OCIError: ORA-01400 [#1174]
114
+ * Rails 5.1 : insert into `returning_id` not working since rails/rails#26002 [#988, #1088]
115
+ * Make `exec_{insert,update}` signatures consistent [#966]
116
+ * Introduce OracleEnhanced `ColumnMethods` module and `AlterTable` `Table` classes [#1081]
117
+ * `empty_insert_statement_value` is not implemented [#1180]
118
+ * Switch to keyword args for `type_to_sql` [#1167, #1168]
119
+ * Replace `all_timestamp_attributes` with `all_timestamp_attributes_in_model` [#1129]
120
+ * `current_database` returns the expected database name [#1135]
121
+ * Use `supports_foreign_keys_in_create?` [#1143]
122
+ * Address `add_column` gets `ArgumentError: wrong number of arguments` [#1157, #1170]
123
+ * Address `change_column` `ArgumentError: wrong number of arguments` [#1171, #1172]
124
+ * SchemaDumper should not dump views as tables [#1192]
125
+ * Use Abstract `select_rows(arel, name = nil, binds = [])` [#1132]
126
+ * Address `OCIError: ORA-01756: quoted string not properly terminated:` [#1102]
127
+ * Use `table_exists?` and `tables` [#1170, #1178]
128
+ * Move `ActiveModel::Type::Text` to `ActiveRecord::Type::Text` [#1082]
129
+ * Support schema option for views [#1190]
130
+ * Quote table and trigger names containing sinqle quote character [#1192]
131
+ * Restore :raw type migration support [#1176]
132
+ * Refactor Boolean type by removing duplicate code [#1047]
133
+ * Remove deprecated methods to get and set columns [#958]
134
+ * Remove `is_?` deprecated methods [#959]
135
+ * Remove `quote_date_with_to_date` and `quote_timestamp_with_to_timestamp` #960
136
+ * Remove unnecessary comments in Type [#961]
137
+ * Remove options[:default] for virtual columns [#962]
138
+ * Remove `self.emulate_dates` and `self.emulate_dates_by_column_name` [#963]
139
+ * Delete `self.boolean_to_string` [#967]
140
+ * Delete Oracle enhanced its own `join_to_update` [#968]
141
+ * Remove `self.ignore_table_columns` [#969]
142
+ * Remove unused `self.virtual_columns` [#970]
143
+ * Remove `dump_schema_information` and `initialize_schema_migrations_table` [#972]
144
+ * Remove `fallback_string_to_date`, `fallback_string_to_time` [#974, #975, #1112]
145
+ * Remove `dependent` option from `add_foreign_key` [#976]
146
+ * Remove specs testing Rails `self.ignored_columns` features [#987]
147
+ * Remove `add_foreign_key` specs with `table_name_prefix` and `table_name_suffix` [#990]
148
+ * Remove `type_cast` method just calling super [#1201]
149
+ * Remove `ids_in_list_limit` alias [#1202]
150
+ * Remove unused comments from data types spec [#1079]
151
+ * Remove deprecated `table_exists?` and `tables` [#1100, #1178]
152
+ * Remove deprecated `name` argument from `#tables` [#1189]
153
+ * Prefer `SYS_CONTEXT` function than `v$nls_parameters` view [#1107]
154
+ * `initialize_schema_migrations_table` method has been removed [#1144]
155
+ * `index_name_exists?` at schema statements spec is not necessary [#1197]
156
+ * Remove comments for `data_source_exists?` [#1200]
157
+ * Address DEPRECATION WARNING: Passing a column to `quote` has been deprecated. [#978]
158
+ * Deprecate `supports_primary_key?` [#1177]
159
+ * Deprecate passing `default` to `index_name_exists?` [#1175]
160
+ * Suppress `add_index_options` method `DEPRECATION WARNING:` [#1193]
161
+ * Suppress `remove_index` method deprecation warning [#1194]
162
+ * Suppress DEPRECATION WARNING at `rename_index` [#1195]
163
+ * Suppress `oracle_enhanced_adapter.rb:591: warning: assigned but unused` [#1198]
164
+ * Use rails rubocop setting [#1111]
165
+ * Rubocop addresses `Extra empty line detected at class body beginning.` [#1078]
166
+ * Address `Lint/EndAlignment` offences by changing code ifself [#1113]
167
+ * rubocop `AlignWith` has been renamed to `EnforcedStyleAlignWith` [#1142]
168
+ * Add `Style/EmptyLinesAroundMethodBody` [#1173]
169
+ * Address git warnings: [#1000]
170
+ * Update `required_rubygems_version` just following rails.gemspec [#1110]
171
+ * Use the latest ruby-plsql while developing alpha version [#1114]
172
+ * Use the latest arel master while developing alpha version [#1115]
173
+ * Bump Arel to 8.0 [#1120, #1121, #1124]
174
+ * Use released Arel 8 [#1205]
175
+ * Remove duplicate license information [#965]
176
+ * Clean up comments and un-commented specs for table comment feature [#971]
177
+ * Use Rails migration `create_table` to create table and sequence [#991]
178
+ * Removed a invalid spec about TIMESTAMP column [#1020]
179
+ * Remove specs which set `attribute :hire_date, :date` [#1024]
180
+ * Remove version specification for rspec [#1055]
181
+ * Suppress `create_table(:test_employees, {:force=>true})` message [#1080]
182
+ * Perform `drop_table :test_employees` [#1087]
183
+ * Address rspec deprecation warning [#1089]
184
+ * Suppress rspec warning [#1101]
185
+ * Suppress `Dropped database 'ORCL'` messages while running rspec [#1103]
186
+ * Address rspec warnings by checking with `raise_errors_for_deprecations!` [#1104]
187
+ * `clear_cache!` always exists at least since Rails 4.0 [#1106]
188
+ * Use SimpleCov [#1108]
189
+ * Enable RSpec `--warnings` option [#1116]
190
+ * Remove entry for rcov since it already migrated to simplecov [#1118]
191
+ * Add spec for #1149 `TypeError: can't cast Java::JavaSql::Timestamp` [#1152]
192
+ * Remove a duplicated specs [#1163]
193
+ * Specify `--require spec_helper` in .rspec [#1186]
194
+ * Add 'pry' and 'pry-nav' for JRuby debug [#973]
195
+ * Remove ruby-debug [#1196]
196
+ * Use Ubuntu Trusty at travis [#1095]
197
+ * Address travis.yml has multilpe language entries [#1109]
198
+ * Use docker-oracle-xe-11g for Travis CI [#1117]
199
+ * Modify `JRUBY_OPTS` for Travis CI [#1119]
200
+ * Add ruby-head and jruby-head to .travis.yml [#1127]
201
+ * Use JRuby 9.1.7.0 [#1138]
202
+ * Add JRuby 9.0.4.0 and allow JRuby 9.0.5.0 failures [#1146]
203
+ * Tiny fix for .travis.yml after migrating to docker-oracle-xe-11g [#1183]
204
+ * Templates updated to use Rails master branch for Rails 5.1 [#1133]
205
+ * Update running tests to include rails-dev-box [#1140]
6
206
 
7
207
  * Known issues
8
- * No changes since 1.7.7
208
+ * Legacy primary key support testing [#1207]
209
+ * PrimaryKeyIntegerNilDefaultTest failures [#1162]
210
+ * Skip `explain should explain query with bind` with JRuby [#1091]
9
211
 
10
212
  ## 1.7.10 / 2017-02-03
11
213
 
data/README.md CHANGED
@@ -6,10 +6,21 @@ Oracle enhanced adapter for ActiveRecord
6
6
  DESCRIPTION
7
7
  -----------
8
8
 
9
- Oracle enhanced ActiveRecord adapter provides Oracle database access from Ruby on Rails applications. Oracle enhanced adapter can be used from Ruby on Rails versions between 2.3.x and 5.0 and it is working with Oracle database versions from 10g to 12c.
9
+ Oracle enhanced ActiveRecord adapter provides Oracle database access from Ruby on Rails applications. Oracle enhanced adapter can be used from Ruby on Rails versions between 2.3.x and 5.1 and it is working with Oracle database versions from 10g to 12c.
10
10
 
11
11
  INSTALLATION
12
12
  ------------
13
+ ### Rails 5.1
14
+
15
+ Oracle enhanced adapter version 1.8 just supports Rails 5.1 and does not support Rails 5.0 or lower version of Rails.
16
+ When using Ruby on Rails version 5.1 then in Gemfile include
17
+
18
+ ```ruby
19
+ # Use oracle as the database for Active Record
20
+ gem 'activerecord-oracle_enhanced-adapter', '~> 1.8.0'
21
+ gem 'ruby-oci8' # only for CRuby users
22
+ ```
23
+
13
24
  ### Rails 5.0
14
25
 
15
26
  Oracle enhanced adapter version 1.7 just supports Rails 5.0 and does not support Rails 4.2 or lower version of Rails.
@@ -630,6 +641,31 @@ development:
630
641
 
631
642
  UPGRADE
632
643
  ---------------
644
+ ### Upgrade Rails 5.0 or older version to Rails 5.1
645
+
646
+ If your application gets `ORA-01000: maximum open cursors exceeded`
647
+ after upgrading to Rails 5.1
648
+ check these two values and configure `:statement_limit` value at database.yml
649
+ is larger than `open_cursors` at Oracle database instance.
650
+
651
+ * `open_cursors` value at Oracle database instance
652
+
653
+ ```sql
654
+ SQL> select name,value from v$parameter where name = 'open_cursors';
655
+
656
+ NAME
657
+ --------------------------------------------------------------------------------
658
+ VALUE
659
+ --------------------------------------------------------------------------------
660
+ open_cursors
661
+ 1200
662
+
663
+ ```
664
+
665
+ * `:statement_limit` value at database.yml
666
+
667
+ Since Oracle enhanced adapter 1.8.0 this default value changed from 250 to 1000.
668
+
633
669
  ### Upgrade Rails 4.2 or older version to Rails 5
634
670
 
635
671
  If your Oracle table columns have been created for Rails `:datetime` attributes in Rails 4.2 or earlier,
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.7.11
1
+ 1.8.2
@@ -1,5 +1,5 @@
1
1
  class ActiveRecord::ConnectionAdapters::OracleAdapter < ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter #:nodoc:
2
2
  def adapter_name
3
- 'Oracle'
3
+ "Oracle"
4
4
  end
5
5
  end
@@ -4,7 +4,6 @@ module ActiveRecord
4
4
  attr_reader :table_name, :nchar, :virtual_column_data_default, :returning_id #:nodoc:
5
5
 
6
6
  def initialize(name, default, sql_type_metadata = nil, null = true, table_name = nil, virtual = false, returning_id = nil, comment = nil) #:nodoc:
7
-
8
7
  @virtual = virtual
9
8
  @virtual_column_data_default = default.inspect if virtual
10
9
  @returning_id = returning_id
@@ -17,7 +16,7 @@ module ActiveRecord
17
16
  # Is column NCHAR or NVARCHAR2 (will need to use N'...' value quoting for these data types)?
18
17
  # Define only when needed as adapter "quote" method will check at first if instance variable is defined.
19
18
  if sql_type_metadata
20
- @object_type = sql_type_metadata.sql_type.include? '.'
19
+ @object_type = sql_type_metadata.sql_type.include? "."
21
20
  end
22
21
  # TODO: Need to investigate when `sql_type` becomes nil
23
22
  end
@@ -62,72 +61,21 @@ module ActiveRecord
62
61
  super
63
62
  end
64
63
 
65
- # Get column comment from schema definition.
66
- # Will work only if using default ActiveRecord connection.
67
- # def comment
68
- # #TODO: may be deprecated due to conflict with variable
69
- # ActiveRecord::Base.connection.column_comment(@table_name, name)
70
- # end
71
-
72
64
  private
73
65
 
74
- def self.extract_value_from_default(default)
75
- case default
66
+ def self.extract_value_from_default(default)
67
+ case default
76
68
  when String
77
69
  default.gsub(/''/, "'")
78
- else
70
+ else
79
71
  default
80
- end
81
- end
82
-
83
- def guess_date_or_time(value)
84
- value.respond_to?(:hour) && (value.hour == 0 and value.min == 0 and value.sec == 0) ?
85
- Date.new(value.year, value.month, value.day) : value
86
- end
87
-
88
- class << self
89
- protected
90
-
91
- def fallback_string_to_date(string) #:nodoc:
92
- if OracleEnhancedAdapter.string_to_date_format || OracleEnhancedAdapter.string_to_time_format
93
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
94
- `fallback_string_to_date` has been deprecated.
95
- It will be removed from next version of Oracle enhanced adapter.
96
- Users are unlikely to see this message since this method has gone
97
- from ActiveRecord::ConnectionAdapters::Column in Rails 4.2.
98
- MSG
99
- return (string_to_date_or_time_using_format(string).to_date rescue super)
100
- end
101
- super
102
- end
103
-
104
- def fallback_string_to_time(string) #:nodoc:
105
- if OracleEnhancedAdapter.string_to_time_format || OracleEnhancedAdapter.string_to_date_format
106
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
107
- `fallback_string_to_time` has been deprecated.
108
- It will be removed from next version of Oracle enhanced adapter.
109
- Users are unlikely to see this message since this method has gone
110
- from ActiveRecord::ConnectionAdapters::Column in Rails 4.2.
111
- MSG
112
- return (string_to_date_or_time_using_format(string).to_time rescue super)
113
72
  end
114
- super
115
73
  end
116
74
 
117
- def string_to_date_or_time_using_format(string) #:nodoc:
118
- ActiveSupport::Deprecation.warn(<<-MSG.squish)
119
- `string_to_date_or_time_using_format` has been deprecated.
120
- It will be removed from next version of Oracle enhanced adapter.
121
- Users are unlikely to see this message since `fallback_string_to_date`
122
- and `fallback_string_to_time` have gone
123
- from ActiveRecord::ConnectionAdapters::Column in Rails 4.2.
124
- MSG
125
- if OracleEnhancedAdapter.string_to_time_format && dt=Date._strptime(string, OracleEnhancedAdapter.string_to_time_format)
126
- return Time.parse("#{dt[:year]}-#{dt[:mon]}-#{dt[:mday]} #{dt[:hour]}:#{dt[:min]}:#{dt[:sec]}#{dt[:zone]}")
127
- end
128
- DateTime.strptime(string, OracleEnhancedAdapter.string_to_date_format).to_date
75
+ def guess_date_or_time(value)
76
+ value.respond_to?(:hour) && ((value.hour == 0) && (value.min == 0) && (value.sec == 0)) ?
77
+ Date.new(value.year, value.month, value.day) : value
129
78
  end
130
- end
131
79
  end
132
80
  end
133
81
  end
@@ -2,66 +2,22 @@ module ActiveRecord #:nodoc:
2
2
  module ConnectionAdapters #:nodoc:
3
3
  module OracleEnhanced #:nodoc:
4
4
  module ColumnDumper #:nodoc:
5
- def column_spec(column)
6
- spec = Hash[prepare_column_options(column).map { |k, v| [k, "#{k}: #{v}"] }]
7
- spec[:name] = column.name.inspect
8
- if column.virtual?
9
- spec[:type] = "virtual"
10
- else
11
- spec[:type] = schema_type(column).to_s
12
- end
13
- spec
14
- end
15
-
16
5
  def prepare_column_options(column)
17
- spec = {}
18
-
19
- if limit = schema_limit(column)
20
- spec[:limit] = limit
21
- end
22
-
23
- if precision = schema_precision(column)
24
- spec[:precision] = precision
25
- end
26
-
27
- if scale = schema_scale(column)
28
- spec[:scale] = scale
29
- end
6
+ spec = super
30
7
 
31
- if virtual_as = schema_virtual_as(column)
32
- spec[:as] = virtual_as
8
+ if supports_virtual_columns? && column.virtual?
9
+ spec[:as] = column.virtual_column_data_default
10
+ spec = { type: schema_type(column).inspect }.merge!(spec) unless column.type == :decimal
33
11
  end
34
12
 
35
- if virtual_type = schema_virtual_type(column)
36
- spec[:virtual_type] = virtual_type
37
- end
38
-
39
- default = schema_default(column) if column.has_default?
40
- spec[:default] = default unless default.nil?
41
-
42
- spec[:null] = 'false' unless column.null
43
-
44
- spec[:comment] = column.comment.inspect if column.comment.present?
45
-
46
13
  spec
47
14
  end
48
15
 
49
- def migration_keys
50
- # TODO `& column_specs.map(&:keys).flatten` should be exetuted here
51
- [:name, :limit, :precision, :scale, :default, :null, :as, :virtual_type, :comment]
52
- end
53
-
54
16
  private
55
17
 
56
- def schema_virtual_as(column)
57
- column.virtual_column_data_default if column.virtual?
58
- end
59
-
60
- def schema_virtual_type(column)
61
- unless column.type == :decimal
62
- column.type.inspect if column.virtual?
18
+ def default_primary_key?(column)
19
+ schema_type(column) == :integer
63
20
  end
64
- end
65
21
  end
66
22
  end
67
23
  end
@@ -29,8 +29,8 @@ module ActiveRecord
29
29
  # Used always by JDBC connection as well by OCI connection when describing tables over database link
30
30
  def describe(name)
31
31
  name = name.to_s
32
- if name.include?('@')
33
- name, db_link = name.split('@')
32
+ if name.include?("@")
33
+ name, db_link = name.split("@")
34
34
  default_owner = select_value("SELECT username FROM all_db_links WHERE db_link = '#{db_link.upcase}'")
35
35
  db_link = "@#{db_link}"
36
36
  else
@@ -38,8 +38,8 @@ module ActiveRecord
38
38
  default_owner = @owner
39
39
  end
40
40
  real_name = ActiveRecord::ConnectionAdapters::OracleEnhanced::Quoting.valid_table_name?(name) ? name.upcase : name
41
- if real_name.include?('.')
42
- table_owner, table_name = real_name.split('.')
41
+ if real_name.include?(".")
42
+ table_owner, table_name = real_name.split(".")
43
43
  else
44
44
  table_owner, table_name = default_owner, real_name
45
45
  end
@@ -65,11 +65,11 @@ module ActiveRecord
65
65
  AND synonym_name = '#{real_name}'
66
66
  SQL
67
67
  if result = select_one(sql)
68
- case result['name_type']
69
- when 'SYNONYM'
68
+ case result["name_type"]
69
+ when "SYNONYM"
70
70
  describe("#{result['owner'] && "#{result['owner']}."}#{result['table_name']}#{db_link}")
71
71
  else
72
- db_link ? [result['owner'], result['table_name'], db_link] : [result['owner'], result['table_name']]
72
+ db_link ? [result["owner"], result["table_name"], db_link] : [result["owner"], result["table_name"]]
73
73
  end
74
74
  else
75
75
  raise OracleEnhancedConnectionException, %Q{"DESC #{name}" failed; does it exist?}
@@ -109,13 +109,13 @@ module ActiveRecord
109
109
  end
110
110
 
111
111
  # if MRI or YARV
112
- if !defined?(RUBY_ENGINE) || RUBY_ENGINE == 'ruby'
112
+ if !defined?(RUBY_ENGINE) || RUBY_ENGINE == "ruby"
113
113
  ORACLE_ENHANCED_CONNECTION = :oci
114
- require 'active_record/connection_adapters/oracle_enhanced/oci_connection'
114
+ require "active_record/connection_adapters/oracle_enhanced/oci_connection"
115
115
  # if JRuby
116
- elsif RUBY_ENGINE == 'jruby'
116
+ elsif RUBY_ENGINE == "jruby"
117
117
  ORACLE_ENHANCED_CONNECTION = :jdbc
118
- require 'active_record/connection_adapters/oracle_enhanced/jdbc_connection'
118
+ require "active_record/connection_adapters/oracle_enhanced/jdbc_connection"
119
119
  else
120
120
  raise "Unsupported Ruby engine #{RUBY_ENGINE}"
121
121
  end