You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace rescue nil cleanup with drop_table / drop_if_exists
`spec/.../connection_spec.rb` had eighteen idempotent-cleanup sites of
the shape `@conn.execute "DROP <type> <name>" rescue nil`. The bare
`rescue nil` swallows every database error — privilege failures,
ORA-00972 identifier-too-long on 11g, syntax errors — and lets the
spec assert against half-built fixtures (case in point: PR #2686
spent days chasing an `ORA-00972` that the catch-all had hidden).
For TABLE drops, switch to the standard ActiveRecord public API
`drop_table(name, if_exists: true)`. On Oracle 23.4+ that issues
native `DROP TABLE IF EXISTS ...`; on older releases it falls back
to a narrow rescue keyed on ORA-00942 only. The default sequence
(`<table>_seq`) is also cleaned up by `drop_table` automatically,
which is desirable here even though these specific specs don't
create one.
For non-TABLE drops (VIEW, MATERIALIZED VIEW, SYNONYM, PUBLIC
SYNONYM) ActiveRecord has no public API, so call the
`OracleEnhancedAdapter#drop_if_exists(object_type, name, if_exists:,
cascade_constraints:)` helper introduced in PR #2688 directly.
Each call names the object kind explicitly so the rescue narrows
on the right ORA code (VIEW → ORA-00942, MV → ORA-12003, SYNONYM
→ ORA-01434, PUBLIC SYNONYM → ORA-01432).
Net behavior change: the same expected misses are still tolerated,
but unexpected failures (privileges, syntax, identifier limit)
propagate instead of being silently absorbed.
The few CREATE statements that previously also had `rescue nil`
(see `should resolve existing table` and friends) are stripped of
that rescue too — those fixtures are spec preconditions, not
optional, and a real failure should fail the spec rather than be
hidden.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
0 commit comments