Skip to content

feat(DBI): Phase 7 — trace/TraceLevel, DBI->internal, _concat_hash_sorted, dbh defaults#548

Merged
fglock merged 1 commit intomasterfrom
feature/dbi-test-parity-phase7
Apr 23, 2026
Merged

feat(DBI): Phase 7 — trace/TraceLevel, DBI->internal, _concat_hash_sorted, dbh defaults#548
fglock merged 1 commit intomasterfrom
feature/dbi-test-parity-phase7

Conversation

@fglock
Copy link
Copy Markdown
Owner

@fglock fglock commented Apr 23, 2026

Summary

Phase 7 of DBI test-parity work — tightens the semantics of the
pure-Perl DBI shim around tracing, default attributes, and
internal helpers. No Java changes.

Highlights

  • TraceLevel / trace: STORE accepts string flag-specs
    ("SQL|foo|3") and treats undef as a no-op. Statement
    handles now inherit TraceLevel from the parent dbh.
    $dbh->trace($level, $file) routes the 3-arg form to
    DBI::trace so handle-level calls install the process-global
    trace filehandle. parse_trace_flags carps on unknown flags.
  • DBI->internal: now a proper tied outer handle.
    isa('DBI::dr') is true, Attribution / Active return the
    expected values.
  • dbh default attributes: Warn, PrintError, PrintWarn,
    RaiseError, AutoCommit, FetchHashKeyName, LongReadLen,
    etc. are now populated at _new_dbh time with their real-DBI
    defaults.
  • _concat_hash_sorted: rewritten to match real DBI's XS
    semantics (undef passthrough, non-HASH croak, unquoted keys,
    numeric-vs-lexical sort guessing).
  • Unknown-attribute warnings: DBD::_::common FETCH / STORE
    now carp on uppercase-prefixed attributes that aren't in a
    known allow-list, mirroring DBI::PurePerl's
    %is_valid_attribute.

Per-test deltas (direct ./jperl t/X.t)

Test Before After
t/01basics.t 95/130 100/100 (halts on unrelated DBI::hash)
t/05concathash.t 11/41 41/41
t/06attrs.t 136/166 142/166
t/09trace.t 83/99 99/99
t/17handle_error.t 84/84 84/84 maintained

Test plan

  • make passes (all unit tests)
  • ./jperl ~/.cpan/build/DBI-1.647-5/t/09trace.t → 99/99
  • ./jperl ~/.cpan/build/DBI-1.647-5/t/17handle_error.t → 84/84 (no regression)
  • ./jperl ~/.cpan/build/DBI-1.647-5/t/01basics.t
    → 100/100 passing before unrelated halt

Generated with Devin

…at_hash_sorted, dbh defaults

TraceLevel / trace:
  * STORE accepts "SQL|foo|3" strings (routed through
    parse_trace_flags) and treats undef as a no-op, matching real
    DBI's "local $h->{TraceLevel} = undef" idiom.
  * $dbh->trace($level, $file) now routes the 3-arg form to
    DBI::trace so handle-level calls install the process-global
    trace filehandle the same way the class method does.
  * parse_trace_flags carps on unknown flags (when Warn is true).
  * Statement handles inherit TraceLevel from the parent dbh in
    _new_sth.

DBI->internal:
  * Now built through _new_drh so it's a proper tied outer handle
    with FETCH / STORE hitting DBD::_::common. DBD::Switch::dr
    inherits from DBI::dr so isa('DBI::dr') is true. Attribution
    and Active defaults are populated so $switch->{Attribution}
    returns "DBI $VERSION by Tim Bunce".

dbh default attributes:
  * _new_dbh now installs Warn, PrintError / PrintWarn (the
    latter off by default unless `-w`), RaiseError, RaiseWarn,
    AutoCommit, CompatMode, ShowErrorStatement, ChopBlanks,
    LongTruncOk, Executed, ErrCount, FetchHashKeyName, and
    LongReadLen with their real-DBI defaults.
  * DBI.pm's connect wrapper no longer skips re-applying
    user-supplied attrs when a key is already present on the
    dbh; the user's connect attr hash is authoritative.

_concat_hash_sorted:
  * Rewritten to match real DBI's XS behaviour: undef input ->
    undef, non-HASH -> croak, keys unquoted, auto-guess
    numeric-vs-lexical sort when sort_type is undef, $a <=> $b
    or $a cmp $b for numeric sort.

Unknown-attribute warnings:
  * DBD::_::common FETCH / STORE now carp on uppercase-prefixed
    attributes that aren't in a known allow-list (mirroring
    DBI::PurePerl's %is_valid_attribute). Lowercase keys,
    private_*, dbd_*, dbi_* prefixes are always accepted.

Per-test deltas (direct ./jperl):
  * t/01basics.t:     95/130 -> 100/100 (halts on unrelated DBI::hash)
  * t/05concathash.t: 11/41  -> 41/41
  * t/06attrs.t:      136/166 -> 142/166
  * t/09trace.t:      83/99  -> 99/99
  * t/17handle_error.t: 84/84 maintained

Generated with [Devin](https://cli.devin.ai/docs)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fglock fglock force-pushed the feature/dbi-test-parity-phase7 branch from b1767a8 to 21e12e2 Compare April 23, 2026 07:56
@fglock fglock merged commit 3dd5fd4 into master Apr 23, 2026
2 checks passed
@fglock fglock deleted the feature/dbi-test-parity-phase7 branch April 23, 2026 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant