activerecord-oracle_enhanced-adapter 1.8.2 → 5.2.0.beta1

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.
Files changed (67) hide show
  1. checksums.yaml +5 -5
  2. data/History.md +190 -5
  3. data/README.md +10 -10
  4. data/VERSION +1 -1
  5. data/lib/active_record/connection_adapters/emulation/oracle_adapter.rb +2 -0
  6. data/lib/active_record/connection_adapters/oracle_enhanced/column.rb +9 -71
  7. data/lib/active_record/connection_adapters/oracle_enhanced/connection.rb +84 -73
  8. data/lib/active_record/connection_adapters/oracle_enhanced/context_index.rb +12 -12
  9. data/lib/active_record/connection_adapters/oracle_enhanced/database_limits.rb +52 -0
  10. data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +35 -7
  11. data/lib/active_record/connection_adapters/oracle_enhanced/database_tasks.rb +2 -0
  12. data/lib/active_record/connection_adapters/oracle_enhanced/dbms_output.rb +59 -0
  13. data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +379 -402
  14. data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb +7 -1
  15. data/lib/active_record/connection_adapters/oracle_enhanced/lob.rb +46 -0
  16. data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +242 -247
  17. data/lib/active_record/connection_adapters/oracle_enhanced/oci_quoting.rb +9 -1
  18. data/lib/active_record/connection_adapters/oracle_enhanced/procedures.rb +3 -1
  19. data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +25 -9
  20. data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +9 -6
  21. data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +10 -5
  22. data/lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb +48 -51
  23. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +261 -59
  24. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements_ext.rb +2 -34
  25. data/lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb +267 -222
  26. data/lib/active_record/connection_adapters/oracle_enhanced/type_metadata.rb +33 -0
  27. data/lib/active_record/connection_adapters/oracle_enhanced/version.rb +2 -0
  28. data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +136 -547
  29. data/lib/active_record/{oracle_enhanced/type → type/oracle_enhanced}/boolean.rb +4 -2
  30. data/lib/active_record/{oracle_enhanced/type → type/oracle_enhanced}/integer.rb +4 -2
  31. data/lib/active_record/type/oracle_enhanced/json.rb +10 -0
  32. data/lib/active_record/{oracle_enhanced/type → type/oracle_enhanced}/national_character_string.rb +5 -3
  33. data/lib/active_record/type/oracle_enhanced/national_character_text.rb +36 -0
  34. data/lib/active_record/{oracle_enhanced/type → type/oracle_enhanced}/raw.rb +4 -2
  35. data/lib/active_record/{oracle_enhanced/type → type/oracle_enhanced}/string.rb +4 -2
  36. data/lib/active_record/{oracle_enhanced/type → type/oracle_enhanced}/text.rb +4 -2
  37. data/lib/active_record/type/oracle_enhanced/timestampltz.rb +25 -0
  38. data/lib/active_record/{oracle_enhanced/type → type/oracle_enhanced}/timestamptz.rb +4 -2
  39. data/lib/activerecord-oracle_enhanced-adapter.rb +2 -6
  40. data/spec/active_record/connection_adapters/{oracle_enhanced_emulate_oracle_adapter_spec.rb → emulation/oracle_adapter_spec.rb} +2 -0
  41. data/spec/active_record/connection_adapters/{oracle_enhanced_connection_spec.rb → oracle_enhanced/connection_spec.rb} +82 -38
  42. data/spec/active_record/connection_adapters/{oracle_enhanced_context_index_spec.rb → oracle_enhanced/context_index_spec.rb} +20 -16
  43. data/spec/active_record/connection_adapters/{oracle_enhanced_database_tasks_spec.rb → oracle_enhanced/database_tasks_spec.rb} +17 -5
  44. data/spec/active_record/connection_adapters/{oracle_enhanced_dbms_output_spec.rb → oracle_enhanced/dbms_output_spec.rb} +2 -0
  45. data/spec/active_record/connection_adapters/{oracle_enhanced_procedures_spec.rb → oracle_enhanced/procedures_spec.rb} +26 -33
  46. data/spec/active_record/connection_adapters/oracle_enhanced/quoting_spec.rb +196 -0
  47. data/spec/active_record/connection_adapters/{oracle_enhanced_schema_dump_spec.rb → oracle_enhanced/schema_dumper_spec.rb} +61 -90
  48. data/spec/active_record/connection_adapters/{oracle_enhanced_schema_statements_spec.rb → oracle_enhanced/schema_statements_spec.rb} +95 -28
  49. data/spec/active_record/connection_adapters/{oracle_enhanced_structure_dump_spec.rb → oracle_enhanced/structure_dump_spec.rb} +48 -2
  50. data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +202 -331
  51. data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +15 -1106
  52. data/spec/active_record/oracle_enhanced/type/binary_spec.rb +119 -0
  53. data/spec/active_record/oracle_enhanced/type/boolean_spec.rb +207 -0
  54. data/spec/active_record/{connection_adapters/oracle_enhanced_dirty_spec.rb → oracle_enhanced/type/dirty_spec.rb} +3 -1
  55. data/spec/active_record/oracle_enhanced/type/float_spec.rb +48 -0
  56. data/spec/active_record/oracle_enhanced/type/integer_spec.rb +91 -0
  57. data/spec/active_record/oracle_enhanced/type/json_spec.rb +57 -0
  58. data/spec/active_record/oracle_enhanced/type/national_character_string_spec.rb +55 -0
  59. data/spec/active_record/oracle_enhanced/type/national_character_text_spec.rb +230 -0
  60. data/spec/active_record/oracle_enhanced/type/raw_spec.rb +122 -0
  61. data/spec/active_record/oracle_enhanced/type/text_spec.rb +229 -0
  62. data/spec/active_record/oracle_enhanced/type/timestamp_spec.rb +75 -0
  63. data/spec/spec_helper.rb +15 -1
  64. data/spec/support/alter_system_set_open_cursors.sql +1 -0
  65. metadata +63 -48
  66. data/lib/active_record/connection_adapters/oracle_enhanced/column_dumper.rb +0 -28
  67. data/lib/active_record/oracle_enhanced/type/json.rb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 955c1c3d11ce8928038c4f64681234c4cf7ad304
4
- data.tar.gz: c08040c3b024d62a76653409df2cda7e723a7ce6
2
+ SHA256:
3
+ metadata.gz: 756277df9a862718b6a18af9b3ff476e12a2497c45d8bdcfdaf47d4be0ebff8b
4
+ data.tar.gz: e970bf14ed9a4eec4b85c67c50c804ffa6a4e52a788a0d95463dfd44b5453ce8
5
5
  SHA512:
6
- metadata.gz: 758ddc44a6c42afe6a160142c5d6d489bb5c4f240333d1ce715e7434f4da57240a46f84207b1160fe831bd0489a76e23e21cea4515b159bc01ade69379cc1620
7
- data.tar.gz: a95939add8ff9aebaf535aeb4d293f0466dcde14479e0ccf4fdbdcf54f37b23e34924f793b54975dc06e0e0e24ec24406b441a6106a071946f7dcf25bd4fb04c
6
+ metadata.gz: 750450b6486e4d3289e4131dd98e433eef87f37e23d20004729cb2fffe6564e98f476a08afe987cad7f673499ded21903300a31a19bed7f3ff0a18f735fd5de5
7
+ data.tar.gz: dead151bdc335ee36ac65e1c8b50679fedc1d1a388b314e3f71dce6a79186ebd893fb261e97018a9773c3e65820daf465e47177e5f9ed949a7c2c4fee4f2b837
data/History.md CHANGED
@@ -1,3 +1,188 @@
1
+ ## 5.2.0.beta1 / 2017-11-27
2
+
3
+ * Major changes and fixes
4
+
5
+ * Support Rails 5.2.0.beta1 [Not released yet but this history will be available when Rails 5.2.0.beta1 is available]
6
+ * Oracle enhanced adapter version follows Rails versioning [#1488]
7
+ * Handle `TIMESTAMP WITH TIMEZONE` separately from `TIMEZONE` [#1267]
8
+ * Support `timestamptz` and `timestampltz` for migrations #1285
9
+ * `supports_json?` returns false [#1562]
10
+ * Add synonyms in `data_sources` [#1380, #1567]
11
+ * Add sequence with settings to structure dump [#1354]
12
+ * Support for NCLOB datatype [#1428, #1440]
13
+ * Use conventional fixture load [#1366]
14
+ * Address `ORA-00905: missing keyword: EXPLAIN PLAN FOR` [#1384]
15
+ * Use new method name for active record dirty checks [#1406]
16
+ * check for schema name when validating table name [#1408, #1410]
17
+ * Prefer to place a table options before `force: :cascade` [#1457]
18
+ * Enable TCP keepalive for OCI connections [#1489]
19
+ * Do not expose `all_schema_indexes` [#1495]
20
+ * Using bind variables for dictionary access [#1498]
21
+ * Use bind variables for `table_comment` `column_comment` `foreign_keys` [#1502]
22
+ * Respect database instance `cursor_sharing` value `exact` by default [#1503, #1556]
23
+ * Address `CommentTest#test_change_table_comment_to_nil` failure [#1504]
24
+ * Address explain with binds errors [#908, #1386, #1538]
25
+ * Address `MigrationTest#test_create_table_with_query_from_relation` error [#1543]
26
+ * Follow the new interface of AR::ConnectionAdapters::IndexDefinition#initialize [#1295]
27
+ * Remove `lengths`, `where`, `using` from `IndexDefinition` [#1529]
28
+ * Arity change in insert method [#1382]
29
+ * Restore the ability that SQL with binds for `insert` [#1424]
30
+ * Restore `to_sql` to return only SQL [#1423]
31
+ * Signature fix for `select_one` `select_value` `select_values` [#1475]
32
+ * `columns` second argument does not exist in Abstract adapter [#1519]
33
+ * Arel::Nodes::BindParam#initialize introduced [#1383]
34
+ * Log the purpose of sql in `disable_referential_integrity` [#1550]
35
+ * Change log format of "Primary Key Trigger" to one line [#1551]
36
+ * Log multi lines SQL statements into one line [#1553]
37
+ * Log multi lines SQL statements into one line at `structure_dump.rb` [#1555]
38
+ * [ci skip] `open_cursors` value should be larger than `:statement_limit` [#1573]
39
+ * [skip ci] Add `schema` option in the comment [#1574]
40
+ * [skip ci] `emulate_booleans_from_strings` behavior changes [#1576]
41
+ * Restore calling `OCIConnection#bind_returning_param` [#1581]
42
+ * Add these errors to be recognized as `ActiveRecord::StatementInvalid` [#1584]
43
+ * Add `ORA-02289` to be recognized as `ActiveRecord::StatementInvalid` [#1586]
44
+ * Address `BasicsTest#test_clear_cache!` failure [#1587]
45
+ * Use Bundler 1.15 to workaround bundler/bundler#6072 [#1590]
46
+ * Translate `ORA-00060` into `ActiveRecord::Deadlocked` error [#1591]
47
+ * Add `ORA-02449` to be recognized as `ActiveRecord::StatementInvalid` [#1593, #1596]
48
+ * Support `discard!` method [#1598]
49
+
50
+ * Deprecation or removing deprecated code
51
+
52
+ * Remove `OracleEnhancedAdapter.cache_columns` [#1490, #1492]
53
+ * Deprecate `supports_statement_cache?` [#1321]
54
+ * Remove `compress_lines` [#1327]
55
+ * Remove `OracleEnhanced::SchemaDumper::TableInspect` [#1400]
56
+ * Remove `remove_prefix_and_suffix` and specs from Oracle enhanced adapter [#1420]
57
+ * Remove unused returning value `stream` [#1438]
58
+ * Remove `OracleEnhancedAdapter.emulate_dates` [#1448]
59
+ * Remove `emulate_dates` and `emulate_dates_by_column_name` [#1450]
60
+ * Remove `emulate_integers_by_column_name` [#1451]
61
+ * Remove `@@do_not_prefetch_primary_key` class variable [#1496]
62
+ * Remove `string_to_date` which has been removed from Rails 4.2 [#1509]
63
+ * Remove `string_to_time` which has been removed from Rails 4.2 [#1510]
64
+ * Remove `guess_date_or_time` which has not been called [#1511]
65
+ * Remove unused `object_type?` and `object_type` ivar [#1512]
66
+ * Remove non-existent `:nchar` from `attr_reader` [#1513]
67
+ * Remove `ActiveRecord::ConnectionAdapter::OracleEnhanced::Column#lob?` [#1522]
68
+ * Remove `OracleEnhanced::Column#returning_id?` [#1523]
69
+ * Remove `attr_reader :table_name` [#1524]
70
+ * Remove `combine_bind_parameters` [#1527]
71
+ * Remove `OracleEnhancedAdapter.default_tablespaces[native_database_types[type][:name]]` [#1544]
72
+ * Remove unused `require "digest/sha1"` [#1545]
73
+ * Remove deprecations for 5.2 [#1548]
74
+ * Remove `OracleEnhanced::Connection#select_values` [#1558]
75
+ * Remove `@connection` from `@connection.oracle_downcase` and `@connection.select_value` [#1559]
76
+ * Rename `OracleEnhanced::Connection#select_value` to `_select_value` [#1563]
77
+ * Rename `OracleEnhanced::Connection#oracle_downcase` to `_oracle_downcase` [#1565]
78
+ * Remove `OCIConnection#typecast_result_value` handling `OraNumber` [#1578]
79
+ * [skip ci] Changing `NLS_DATE_FORMAT` and `NLS_TIMESTAMP_FORMAT` is not supported [#1575]
80
+ * [skip ci] Remove ruby versions in the comment [#1577]
81
+ * Remove `OCIConnection#returning_clause` and `JDBCConnection#returning_clause` [#1579]
82
+ * Remove `OCIConnection#exec_with_returning` and `JDBCConnection#exec_with_returning` [#1580]
83
+ * Update `JDBCConnection#bind_param` case condition [#1583]
84
+
85
+ * Refactoring
86
+
87
+ * Refactor `SchemaDumper` to make it possible to adapter specific customization [#1430]
88
+ * Rename `SchemaDumper#indexes` to `SchemaDumper#_indexes` [#1399]
89
+ * Use ActiveRecord::Type::Json [#1352]
90
+ * Introduce module `DatabaseLimits` [#1322]
91
+ * Move `oracle_downcase` to `Quoting` module [#1328]
92
+ * Make `type_map` to private because it is only used in the connection adapter [#1381]
93
+ * Remove `add_runtime_dependency` with arel [#1385]
94
+ * Move methods for synonyms out of `SchemaStatementsExt` [#1387]
95
+ * Remove incorrect prepend to `ActiveRecord::ColumnDumper` [#1394]
96
+ * Handle `ActiveRecord::SchemaDumper` by `adapter_name` [#1395]
97
+ * Rewrite `remove_prefix_and_suffix` to be similar with super #1401
98
+ * `remove_prefix_and_suffix` handles dollar sign by `Regexp#escape` [#1402]
99
+ * `prepare_column_options` is now private [#1429]
100
+ * Introduce `OracleEnhanced::SchemaStatements#table_options` [#1439]
101
+ * Extract `ActiveRecord::ConnectionAdapters::OracleEnhanced::Column` [#1445]
102
+ * Extract `ActiveRecord::ConnectionAdapters::OracleEnhanced::DbmsOutput` [#1446]
103
+ * Introduce `SchemaDumpingHelper#dump_table_schema` [#1455]
104
+ * Rename `OracleEnhancedConnection` to `OracleEnhanced::Connection` [#1477]
105
+ * Introduce `ActiveRecord::ConnectionAdapters::OracleEnhanced::TypeMetadata` [#1515]
106
+ * Change `schema_creation` to private [#1517]
107
+ * Change `create_table_definition` and `fetch_type_metadata` to private [#1518]
108
+ * Refactor `columns` [#1521]
109
+ * Let `ActiveRecord::ConnectionAdapters::OracleEnhanced::TypeMetadata` handle `virtual` type [#1526]
110
+ * Clean up `column_definitions` method [#1528]
111
+ * Remove unnecessary `ActiveRecord::ConnectionAdapters` [#1530]
112
+ * Rename `OracleEnhancedStructureDump` to `OracleEnhanced::StructureDump` [#1531]
113
+ * Move up require for types [#1533]
114
+ * These methods are private in `AbstractAdapter` or `PostgreSQLAdapter` [#1534]
115
+ * `ActiveRecord::ConnectionAdapters::AbstractAdapter#log` is a `private` [#1535]
116
+ * Move `self.default_sequence_start_value` method [#1536]
117
+ * Rename `ActiveRecord::OracleEnhanced::Type` to `ActiveRecord::Type::OracleEnhanced` [#1541]
118
+ * Move `write_lobs` under `OracleEnhanced::DatabaseStatements` module [#1546]
119
+ * Introduce `OracleEnhanced::Lob` not to modify `ActiveRecord::Base` directly [#1547]
120
+ * Use `ActiveSupport.on_load` to hook into `ActiveRecord::Base` [#1568]
121
+ * Call `virtual_columns_for` when `supports_virtual_columns?` returns true [#1554]
122
+ * Move `tables` and related methods into `OracleEnhanced::SchemaStatements` [#1557]
123
+ * Avoid using `OracleEnhanced::Connection#select_value` [#1560]
124
+ * Make `OracleEnhanced::Connection#describe` private [#1566]
125
+
126
+ * Changes in specs
127
+
128
+ * Always generate `debug.log` for unit tests [#1476]
129
+ * Use Rails migration for creating table at "using offset and limit" [#1276]
130
+ * Use Rails migration for creating table at `valid_type?` [#1277]
131
+ * Clean up before(:each) and after(:each) at "rename tables and sequences" [#1278]
132
+ * Use Rails migration for creating table at `BINARY_FLOAT columns" specs [#1280]
133
+ * Use Rails migration for creating table at "handling of BLOB columns" [#1282]
134
+ * Use Rails migration for creating table at "handling of CLOB columns" [#1283]
135
+ * Use Rails migration for creating table at "assign string to :date and :datetime columns" [#1284]
136
+ * Use Rails migration for creating table at "table columns" [#1287]
137
+ * Use Rails migration for creating table at procedure specs [#1288]
138
+ * Use Rails migration for creating table at database tasks specs [#1290]
139
+ * Suppress `warning: assigned but unused variable - poolable_connection_factory` [#1292]
140
+ * Suppress `warning: assigned but unused variable - post` [#1293]
141
+ * Move spec files under `oracle_enhanced` directory [#1441]
142
+ * Move spec files under `emulation` directory [#1442]
143
+ * Move schema_dumper_spec under `oracle_enhanced` directory [#1443]
144
+ * Rename spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb [#1447]
145
+ * Remove `set_boolean_columns` from `oracle_enhanced_data_types_spec.rb` [#1452]
146
+ * Remove `set_string_columns` from `oracle_enhanced_data_types_spec.rb` [#1454]
147
+ * Use `drop_table` if_exists: true` to avoid rescue nil [#1456]
148
+ * Extract JSON data type specs [#1459]
149
+ * Extract NationalCharacterString data type specs [#1460]
150
+ * Extract RAW data type specs [#1461]
151
+ * Extract TEXT data type specs [#1462]
152
+ * Extract INTEGER data type specs [#1463]
153
+ * Remove redundant `type` from spec files [#1464]
154
+ * Extract boolean data type specs [#1465]
155
+ * Extract NationalCharacterText data type specs [#1466]
156
+ * Extract specs for `OracleEnhanced::Quoting` [#1469]
157
+ * Extract TIMPSTAMP, TIMESTAMPTZ and TIMESTAMPLTZ specs [#1480]
158
+ * Extract FLOAT type specs [#1482]
159
+ * Use `SchemaDumpingHelper#dump_table_schema` at `context_index_spec` [#1491]
160
+ * Remove unused `fk_name` [#1514]
161
+ * Show correct bind value information in debug.log [#1537]
162
+ * rubocop 0.48.1 [#1281]
163
+
164
+ * Changes for CI and builds
165
+
166
+ * Use `rubocop-0-51` channel on Code Climate [#1589]
167
+ * Use `rubocop-0-50` channel on Code Climate [#1539]
168
+ * Use `rubocop-0-49` channel to run rubocop 0.49 [#1478]
169
+ * Bump ruby versions to 2.4.2, 2.3.5 and 2.2.8 at Travis [#1484]
170
+ * CI against JRuby 9.1.14.0 [#1592]
171
+ * CI against JRuby 9.1.13.0 [#1471]
172
+ * set `open_cursor` value to `1200` [#1431]
173
+ * Use bundler 1.16.0.preX and update rubygems to the latest [#1532]
174
+ * [ci skip] Create an issue template [#1317]
175
+ * [ci skip] Add Oracle enhanced adapter version to the issue template [#1319]
176
+ * [ci skip] Remove `self.emulate_integers_by_column_name = true` [#1494]
177
+ * Remove leftover comments [ci skip] [#1520]
178
+ * Move issue template to github sub directory [skip ci] [#1320]
179
+ * Replace :github source with https [#1499]
180
+ * Simplify `git_source` in Gemfile [#1500]
181
+ * Enable and apply `Style/Semicolon` [#1570]
182
+ * Enable and apply Style/RedundantReturn [#1571]
183
+ * Enable `Style/DefWithParentheses` rubocop rule [#1597]
184
+ * bundler 1.16.0 is out, no more --pre [#1572]
185
+
1
186
  ## 1.8.2 / 2017-08-24
2
187
 
3
188
  * Changes and bug fixes
@@ -10,7 +195,7 @@
10
195
  * Bump ruby versions [#1346]
11
196
  * rubocop namespace changes from `Style` to `Layout` [#1347, #1351]
12
197
 
13
- * Changes and bug fixes
198
+ * Known issues
14
199
  * No changes since 1.8.0.rc3
15
200
 
16
201
  ## 1.8.1 / 2017-05-11
@@ -579,7 +764,7 @@
579
764
  * Address undefined method `cast_type' [#805]
580
765
  * Better fix to support "Relation#count does not support finder options anymore in Rails [#788, #787]
581
766
  * ActiveRecord::Calculations#count no longer accepts an options hash argument #754
582
- * Supress WARNINGs using `raise_error` without specific errors [#724]
767
+ * Suppress WARNINGs using `raise_error` without specific errors [#724]
583
768
  * Use RSpec 3 [#707]
584
769
  * Update "OracleEnhancedAdapter boolean type detection based on string column types and names" [#873]
585
770
  * Update "OracleEnhancedAdapter integer type detection based on column names" [#871]
@@ -866,7 +1051,7 @@
866
1051
  * Update README to support assignment methods [#365]
867
1052
  * Remove add_limit_offset! method [#369]
868
1053
  * Update Gemfile to use `bundle config --local` [#370]
869
- * `describe` does not try super when no datbase link and ORA-4043 returned [#375]
1054
+ * `describe` does not try super when no database link and ORA-4043 returned [#375]
870
1055
  * Support `remove_columns` [#377]
871
1056
  * Dump views in alphabetical order and add `FORCE` option [#378]
872
1057
 
@@ -1251,10 +1436,10 @@
1251
1436
  * Forked from original activerecord-oracle-adapter-1.0.0.9216
1252
1437
  * Renamed oracle adapter to oracle_enhanced adapter
1253
1438
  * Added "enhanced" to method and class definitions so that oracle_enhanced and original oracle adapter
1254
- could be used simultaniously
1439
+ could be used simultaneously
1255
1440
  * Added Rails rake tasks as a copy from original oracle tasks
1256
1441
  * Enhancements:
1257
- * Improved perfomance of schema dump methods when used on large data dictionaries
1442
+ * Improved performance of schema dump methods when used on large data dictionaries
1258
1443
  * Added LOB writing callback for sessions stored in database
1259
1444
  * Added emulate_dates_by_column_name option
1260
1445
  * Added emulate_integers_by_column_name option
data/README.md CHANGED
@@ -239,12 +239,6 @@ ENV['TZ'] = 'UTC'
239
239
 
240
240
  ActiveSupport.on_load(:active_record) do
241
241
  ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.class_eval do
242
- # id columns and columns which end with _id will always be converted to integers
243
- self.emulate_integers_by_column_name = true
244
-
245
- # DATE columns which include "date" in name will be converted to Date, otherwise to Time
246
- self.emulate_dates_by_column_name = true
247
-
248
242
  # true and false will be stored as 'Y' and 'N'
249
243
  self.emulate_booleans_from_strings = true
250
244
 
@@ -481,7 +475,7 @@ Post.contains(:all_text, "aaa within title")
481
475
  Post.contains(:all_text, "bbb within comment_author")
482
476
  ```
483
477
 
484
- Please note that `index_column` must be a real column in your database and it's value will be overriden every time your `index_column_trigger_on` columns are changed. So, _do not use columns with real data as `index_column`_.
478
+ Please note that `index_column` must be a real column in your database and it's value will be overridden every time your `index_column_trigger_on` columns are changed. So, _do not use columns with real data as `index_column`_.
485
479
 
486
480
  Index column can be created as:
487
481
 
@@ -639,14 +633,20 @@ development:
639
633
  )"
640
634
  ```
641
635
 
636
+ ### Schema cache
637
+
638
+ `rails db:schema:cache:dump` generates `db/schema_cache.yml` to avoid queries for Oracle database dictionary, which could help your application response time if it takes time to look up database structure.
639
+
640
+ if any database structure changed by migrations, execute `rails db:schema:cache:dump` again and restart Rails server to reflect changes.
641
+
642
642
  UPGRADE
643
643
  ---------------
644
644
  ### Upgrade Rails 5.0 or older version to Rails 5.1
645
645
 
646
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.
647
+ after upgrading to Rails 5.1,
648
+ check these two values and configure `open_cursors` parameter value
649
+ at Oracle database instance is larger than `:statement_limit` value at database.yml.
650
650
 
651
651
  * `open_cursors` value at Oracle database instance
652
652
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.8.2
1
+ 5.2.0.beta1
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class ActiveRecord::ConnectionAdapters::OracleAdapter < ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter #:nodoc:
2
4
  def adapter_name
3
5
  "Oracle"
@@ -1,81 +1,19 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveRecord
2
4
  module ConnectionAdapters #:nodoc:
3
- class OracleEnhancedColumn < Column
4
- attr_reader :table_name, :nchar, :virtual_column_data_default, :returning_id #:nodoc:
5
+ module OracleEnhanced
6
+ class Column < ActiveRecord::ConnectionAdapters::Column
7
+ delegate :virtual, to: :sql_type_metadata, allow_nil: true
5
8
 
6
- def initialize(name, default, sql_type_metadata = nil, null = true, table_name = nil, virtual = false, returning_id = nil, comment = nil) #:nodoc:
7
- @virtual = virtual
8
- @virtual_column_data_default = default.inspect if virtual
9
- @returning_id = returning_id
10
- if virtual
11
- default_value = nil
12
- else
13
- default_value = self.class.extract_value_from_default(default)
14
- end
15
- super(name, default_value, sql_type_metadata, null, table_name, comment: comment)
16
- # Is column NCHAR or NVARCHAR2 (will need to use N'...' value quoting for these data types)?
17
- # Define only when needed as adapter "quote" method will check at first if instance variable is defined.
18
- if sql_type_metadata
19
- @object_type = sql_type_metadata.sql_type.include? "."
9
+ def initialize(name, default, sql_type_metadata = nil, null = true, table_name = nil, comment = nil) #:nodoc:
10
+ super(name, default, sql_type_metadata, null, table_name, comment: comment)
20
11
  end
21
- # TODO: Need to investigate when `sql_type` becomes nil
22
- end
23
-
24
- def virtual?
25
- @virtual
26
- end
27
-
28
- def returning_id?
29
- @returning_id
30
- end
31
-
32
- def lob?
33
- self.sql_type =~ /LOB$/i
34
- end
35
-
36
- def object_type?
37
- @object_type
38
- end
39
12
 
40
- # convert something to a boolean
41
- # added y as boolean value
42
- def self.value_to_boolean(value) #:nodoc:
43
- if value == true || value == false
44
- value
45
- elsif value.is_a?(String) && value.blank?
46
- nil
47
- else
48
- %w(true t 1 y +).include?(value.to_s.downcase)
13
+ def virtual?
14
+ virtual
49
15
  end
50
16
  end
51
-
52
- # convert Time or DateTime value to Date for :date columns
53
- def self.string_to_date(string) #:nodoc:
54
- return string.to_date if string.is_a?(Time) || string.is_a?(DateTime)
55
- super
56
- end
57
-
58
- # convert Date value to Time for :datetime columns
59
- def self.string_to_time(string) #:nodoc:
60
- return string.to_time if string.is_a?(Date) && !OracleEnhancedAdapter.emulate_dates
61
- super
62
- end
63
-
64
- private
65
-
66
- def self.extract_value_from_default(default)
67
- case default
68
- when String
69
- default.gsub(/''/, "'")
70
- else
71
- default
72
- end
73
- end
74
-
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
78
- end
79
17
  end
80
18
  end
81
19
  end
@@ -1,49 +1,43 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ActiveRecord
2
4
  module ConnectionAdapters
3
5
  # interface independent methods
4
- class OracleEnhancedConnection #:nodoc:
5
- def self.create(config)
6
- case ORACLE_ENHANCED_CONNECTION
7
- when :oci
8
- OracleEnhancedOCIConnection.new(config)
9
- when :jdbc
10
- OracleEnhancedJDBCConnection.new(config)
11
- else
12
- nil
6
+ module OracleEnhanced
7
+ class Connection #:nodoc:
8
+ def self.create(config)
9
+ case ORACLE_ENHANCED_CONNECTION
10
+ when :oci
11
+ OracleEnhanced::OCIConnection.new(config)
12
+ when :jdbc
13
+ OracleEnhanced::JDBCConnection.new(config)
14
+ else
15
+ nil
16
+ end
13
17
  end
14
- end
15
18
 
16
- attr_reader :raw_connection
19
+ attr_reader :raw_connection
17
20
 
18
- # Oracle column names by default are case-insensitive, but treated as upcase;
19
- # for neatness, we'll downcase within Rails. EXCEPT that folks CAN quote
20
- # their column names when creating Oracle tables, which makes then case-sensitive.
21
- # I don't know anybody who does this, but we'll handle the theoretical case of a
22
- # camelCase column name. I imagine other dbs handle this different, since there's a
23
- # unit test that's currently failing test_oci.
24
- def oracle_downcase(column_name)
25
- return nil if column_name.nil?
26
- column_name =~ /[a-z]/ ? column_name : column_name.downcase
27
- end
21
+ private
28
22
 
29
- # Used always by JDBC connection as well by OCI connection when describing tables over database link
30
- def describe(name)
31
- name = name.to_s
32
- if name.include?("@")
33
- name, db_link = name.split("@")
34
- default_owner = select_value("SELECT username FROM all_db_links WHERE db_link = '#{db_link.upcase}'")
35
- db_link = "@#{db_link}"
36
- else
37
- db_link = nil
38
- default_owner = @owner
39
- end
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(".")
43
- else
44
- table_owner, table_name = default_owner, real_name
45
- end
46
- sql = <<-SQL
23
+ # Used always by JDBC connection as well by OCI connection when describing tables over database link
24
+ def describe(name)
25
+ name = name.to_s
26
+ if name.include?("@")
27
+ name, db_link = name.split("@")
28
+ default_owner = _select_value("SELECT username FROM all_db_links WHERE db_link = '#{db_link.upcase}'")
29
+ db_link = "@#{db_link}"
30
+ else
31
+ db_link = nil
32
+ default_owner = @owner
33
+ end
34
+ real_name = OracleEnhanced::Quoting.valid_table_name?(name) ? name.upcase : name
35
+ if real_name.include?(".")
36
+ table_owner, table_name = real_name.split(".")
37
+ else
38
+ table_owner, table_name = default_owner, real_name
39
+ end
40
+ sql = <<-SQL.strip.gsub(/\s+/, " ")
47
41
  SELECT owner, table_name, 'TABLE' name_type
48
42
  FROM all_tables#{db_link}
49
43
  WHERE owner = '#{table_owner}'
@@ -64,46 +58,63 @@ module ActiveRecord
64
58
  WHERE owner = 'PUBLIC'
65
59
  AND synonym_name = '#{real_name}'
66
60
  SQL
67
- if result = select_one(sql)
68
- case result["name_type"]
69
- when "SYNONYM"
70
- describe("#{result['owner'] && "#{result['owner']}."}#{result['table_name']}#{db_link}")
71
- else
72
- db_link ? [result["owner"], result["table_name"], db_link] : [result["owner"], result["table_name"]]
61
+ if result = _select_one(sql)
62
+ case result["name_type"]
63
+ when "SYNONYM"
64
+ describe("#{result['owner'] && "#{result['owner']}."}#{result['table_name']}#{db_link}")
65
+ else
66
+ db_link ? [result["owner"], result["table_name"], db_link] : [result["owner"], result["table_name"]]
67
+ end
68
+ else
69
+ raise OracleEnhanced::ConnectionException, %Q{"DESC #{name}" failed; does it exist?}
70
+ end
73
71
  end
74
- else
75
- raise OracleEnhancedConnectionException, %Q{"DESC #{name}" failed; does it exist?}
76
- end
77
- end
78
72
 
79
- # Returns a record hash with the column names as keys and column values
80
- # as values.
81
- def select_one(sql)
82
- result = select(sql)
83
- result.first if result
84
- end
73
+ # Oracle column names by default are case-insensitive, but treated as upcase;
74
+ # for neatness, we'll downcase within Rails. EXCEPT that folks CAN quote
75
+ # their column names when creating Oracle tables, which makes then case-sensitive.
76
+ # I don't know anybody who does this, but we'll handle the theoretical case of a
77
+ # camelCase column name. I imagine other dbs handle this different, since there's a
78
+ # unit test that's currently failing test_oci.
79
+ #
80
+ # `_oracle_downcase` is expected to be called only from
81
+ # `ActiveRecord::ConnectionAdapters::OracleEnhanced::OCIConnection`
82
+ # or `ActiveRecord::ConnectionAdapters::OracleEnhanced::JDBCConnection`.
83
+ # Other method should call `ActiveRecord:: ConnectionAdapters::OracleEnhanced::Quoting#oracle_downcase`
84
+ # since this is kind of quoting, not connection.
85
+ # To avoid it is called from anywhere else, added _ at the beginning of the method name.
86
+ def _oracle_downcase(column_name)
87
+ return nil if column_name.nil?
88
+ column_name =~ /[a-z]/ ? column_name : column_name.downcase
89
+ end
85
90
 
86
- # Returns a single value from a record
87
- def select_value(sql)
88
- if result = select_one(sql)
89
- result.values.first
90
- end
91
- end
91
+ # _select_one and _select_value methods are expected to be called
92
+ # only from `ActiveRecord::ConnectionAdapters::OracleEnhanced::Connection#describe`
93
+ # Other methods should call `ActiveRecord::ConnectionAdapters::DatabaseStatements#select_one`
94
+ # and `ActiveRecord::ConnectionAdapters::DatabaseStatements#select_value`
95
+ # To avoid called from its subclass added a underscore in each method.
92
96
 
93
- # Returns an array of the values of the first column in a select:
94
- # select_values("SELECT id FROM companies LIMIT 3") => [1,2,3]
95
- def select_values(sql, name = nil)
96
- result = select(sql, name = nil)
97
- result.map { |r| r.values.first }
98
- end
99
- end
97
+ # Returns a record hash with the column names as keys and column values
98
+ # as values.
99
+ def _select_one(arel, name = nil, binds = [])
100
+ result = select(arel)
101
+ result.first if result
102
+ end
100
103
 
101
- # Returns array with major and minor version of database (e.g. [12, 1])
102
- def database_version
103
- raise NoMethodError, "Not implemented for this raw driver"
104
- end
104
+ # Returns a single value from a record
105
+ def _select_value(arel, name = nil, binds = [])
106
+ if result = _select_one(arel)
107
+ result.values.first
108
+ end
109
+ end
110
+ end
105
111
 
106
- class OracleEnhancedConnectionException < StandardError #:nodoc:
112
+ # Returns array with major and minor version of database (e.g. [12, 1])
113
+ def database_version
114
+ raise NoMethodError, "Not implemented for this raw driver"
115
+ end
116
+ class ConnectionException < StandardError #:nodoc:
117
+ end
107
118
  end
108
119
  end
109
120
  end