Add optional SQL logging spec helper#285
Merged
yahonda merged 2 commits intorsim:masterfrom May 7, 2026
Merged
Conversation
Set PLSQL_DEBUG_LOG=debug.log when running rspec to capture every SQL statement issued by PLSQL::OCIConnection / PLSQL::JDBCConnection (exec, cursor_from_query, parse) plus any SQL emitted via ActiveRecord::Base when specs use plsql.activerecord_class. Logger arguments mirror those used in the activerecord-oracle_enhanced-adapter spec helper. logger is added to the Gemfile because it is a bundled gem on Ruby 3.5+ and would otherwise be unavailable when NO_ACTIVERECORD=1 (which skips activerecord, the gem that pulls logger in transitively).
Match the activerecord-oracle_enhanced-adapter convention of writing spec SQL to debug.log unconditionally. The previous PLSQL_DEBUG_LOG env var gate is removed so debug.log is always available when tests fail, and debug.log is added to .gitignore.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
spec/support/sql_logger.rb: prepend a logging module ontoPLSQL::OCIConnectionandPLSQL::JDBCConnection(exec,cursor_from_query,parse) and routeActiveRecord::Base.loggerto the sameLogger. Every SQL statement issued during a spec run is written todebug.login the working directory.("debug.log", 0, 100 * 1024 * 1024)mirror those used inactiverecord-oracle_enhanced-adapter's spec helper, sodebug.logrotates the same way.debug.logto.gitignore(matching the oracle_enhanced repo's.gitignoreentry).gem "logger"to theGemfilebecauseloggerbecame a bundled gem in Ruby 3.5; without this declaration,NO_ACTIVERECORD=1runs would lose access to it (today it is pulled in transitively only viaactiverecord).Test plan
bundle exec rspec spec/plsql/sequence_spec.rb— passes;debug.logis created and containsEXEC/QUERY/PARSElines for the sequence DDL andSELECT seq.NEXTVAL FROM dualqueries.bundle exec rspec spec/plsql/schema_spec.rb—debug.loginterleaves PL/SQL-side and oracle_enhanced adapter SQL.NO_ACTIVERECORD=1 bundle exec rspec spec/plsql/sequence_spec.rb— works on Ruby 3.5+ thanks to the explicitgem "logger"; only PL/SQL-side SQL is logged.git statusafter a run showsdebug.logignored.