Commit 9068dfa
Sweep
Continues the cleanup begun in PR #2687. The previous PR replaced
`@conn.execute "DROP …" rescue nil` in `connection_spec.rb` with
`drop_table` / `drop_if_exists`, narrowing the rescue to the per-kind
"object does not exist" ORA codes so privilege failures, ORA-00972
identifier-too-long on 11g, syntax errors, etc. propagate instead of
being silently absorbed.
This sweep covers the remaining spec files that used the same
pattern:
oracle_enhanced_data_types_spec.rb
oracle_enhanced/context_index_spec.rb
oracle_enhanced/dbms_metadata_structure_dump_spec.rb
oracle_enhanced/quoting_spec.rb
oracle_enhanced/schema_dumper_spec.rb
oracle_enhanced/schema_statements_spec.rb
oracle_enhanced/structure_dump_spec.rb
The replacements follow the same per-call-site review used in #2687:
- DROP TABLE (+ implicit default `<table>_seq`) → `drop_table(name,
if_exists: true)`. The standard ActiveRecord public API also
cleans up the default sequence, so the explicit DROP SEQUENCE
line in `oracle_enhanced_data_types_spec.rb` is redundant and
drops out.
- DROP <other-object> (VIEW, MATERIALIZED VIEW, SYNONYM, PACKAGE,
FUNCTION, PROCEDURE, TYPE, TRIGGER, SEQUENCE) →
`drop_if_exists("<TYPE>", name)`.
- `remove_foreign_key … rescue nil` → `remove_foreign_key …,
if_exists: true` (already supported by AR).
- `Object.send(:remove_const, "X") rescue nil` →
`Object.send(:remove_const, "X") if Object.const_defined?("X")`.
`structure_dump_spec.rb`'s `after(:each)` had a long pile of
`ALTER TABLE … DROP CONSTRAINT` and `ALTER TABLE … DROP COLUMN`
lines, also wrapped in `rescue nil`. They were redundant: every
constraint and column they removed was on `test_posts` or `foos`,
both of which the same hook drops a few lines later — the
constraints and columns disappear with their parent table. A few of
the names (`UK_FOOZ_BAZ`, `fooz_id`) were not even created by any
test in the file. Simplified to a flat sequence of
view/table/sequence/trigger/type drops in dependency order.
For `remove_context_index`, ActiveRecord has no equivalent helper, so
this commit also extends the Oracle-Enhanced adapter helper itself to
accept `if_exists:`. `remove_context_index(name:, if_exists: true)`
now calls `drop_if_exists("INDEX", index_name, if_exists: …)`
internally and routes the auxiliary trigger / procedure cleanup
through `drop_if_exists` too (replacing the inline `rescue nil`
those private helpers had themselves). The auxiliary
`drop_ctx_preference` PL/SQL call is left as-is for now — Oracle
Text returns DRG-* codes, not ORA-*, and narrowing it requires a
separate per-code audit.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>rescue nil cleanup paths across remaining specs1 parent 68aa2aa commit 9068dfa
8 files changed
Lines changed: 32 additions & 37 deletions
File tree
- lib/active_record/connection_adapters/oracle_enhanced
- spec/active_record/connection_adapters
- oracle_enhanced
Lines changed: 7 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
129 | | - | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
130 | 132 | | |
131 | 133 | | |
132 | 134 | | |
133 | 135 | | |
| 136 | + | |
134 | 137 | | |
135 | 138 | | |
136 | | - | |
| 139 | + | |
137 | 140 | | |
138 | 141 | | |
139 | 142 | | |
140 | | - | |
| 143 | + | |
141 | 144 | | |
142 | 145 | | |
143 | 146 | | |
| |||
291 | 294 | | |
292 | 295 | | |
293 | 296 | | |
294 | | - | |
| 297 | + | |
295 | 298 | | |
296 | 299 | | |
297 | 300 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
207 | | - | |
208 | | - | |
| 207 | + | |
| 208 | + | |
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
181 | | - | |
| 181 | + | |
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
| 185 | + | |
186 | 186 | | |
187 | 187 | | |
188 | 188 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
200 | 200 | | |
201 | 201 | | |
202 | 202 | | |
203 | | - | |
204 | | - | |
| 203 | + | |
| 204 | + | |
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
| |||
Lines changed: 3 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
133 | | - | |
134 | | - | |
| 133 | + | |
| 134 | + | |
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| |||
326 | 326 | | |
327 | 327 | | |
328 | 328 | | |
329 | | - | |
| 329 | + | |
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1459 | 1459 | | |
1460 | 1460 | | |
1461 | 1461 | | |
1462 | | - | |
| 1462 | + | |
1463 | 1463 | | |
1464 | 1464 | | |
1465 | 1465 | | |
| |||
Lines changed: 14 additions & 21 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
| 40 | + | |
39 | 41 | | |
40 | 42 | | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
54 | 47 | | |
55 | 48 | | |
56 | 49 | | |
| |||
470 | 463 | | |
471 | 464 | | |
472 | 465 | | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
473 | 473 | | |
474 | 474 | | |
475 | | - | |
476 | | - | |
477 | | - | |
478 | | - | |
479 | | - | |
480 | | - | |
481 | | - | |
482 | 475 | | |
483 | 476 | | |
484 | 477 | | |
| |||
540 | 533 | | |
541 | 534 | | |
542 | 535 | | |
543 | | - | |
| 536 | + | |
544 | 537 | | |
545 | 538 | | |
546 | 539 | | |
| |||
Lines changed: 1 addition & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
9 | 8 | | |
10 | 9 | | |
11 | 10 | | |
| |||
0 commit comments