Skip to content

Conversation

@rolandwalker
Copy link
Contributor

Description

In tabulate_adapter.adapter(), permit the colalign argument to be passed in kwargs.

This argument can be used by the application to set known desirable column alignments based on column types, without expensive numparse checks.

In addition, this works reliably with nullable numeric columns, whereas the numparse logic does not.

xref #96 which never was able to work.
xref dbcli/mycli#1102 which this intends to fix.

Checklist

  • I've added this contribution to the CHANGELOG.
  • I've added my name to the AUTHORS file (or it's already there).
  • I installed pre-commit hooks (pip install pre-commit && pre-commit install), and ran black on my code.
  • Please squash merge this pull request (uncheck if you'd like us to merge as multiple commits)

In tabulate_adapter.adapter(), permit the colalign argument to be passed
in kwargs.

This argument can be used by the application to set known desirable
column alignments based on column types, without expensive numparse
checks.

In addition, this works reliably with nullable numeric columns, whereas
the numparse logic does not.
@rolandwalker rolandwalker self-assigned this Jan 24, 2026
@rolandwalker rolandwalker merged commit 53f7a61 into main Jan 24, 2026
2 checks passed
@rolandwalker rolandwalker deleted the RW/pass-through-colalign-argument branch January 24, 2026 14:19
rolandwalker added a commit to dbcli/mycli that referenced this pull request Jan 24, 2026
After dbcli/cli_helpers#97 we can set the
alignment on a per-column basis using the colalign parameter.

In this PR we upgrade cli_helpers and set colalign for columns with
a numeric type.  This is more performant than using tabulate's
numparse capability, and unlike numparse, works on nullable numeric
columns.

The default alignment for numeric columns is changed from left to
right, on the basis that this is the default for the vendor client.
However, the user is free to change it back in ~/.myclirc .
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.

2 participants