docs: fix %-d example in date specifier table - #6138
Conversation
prql-bot
left a comment
There was a problem hiding this comment.
Verified the change by compiling against the Postgres dialect: date.to_text "%-d" emits TO_CHAR(d, 'FMDD'), and the FM prefix suppresses padding entirely — so 8 is the right example and the previous 8 was wrong.
One adjacent thing the same table gets wrong, outside this diff and left for a separate decision: the %k row (Same as %H but space-padded. Same as %_H.) is listed under "specifiers currently supported", but prqlc rejects it. chrono parses %k as Item::Numeric(Numeric::Hour, Pad::Space), and no dialect's translate_chrono_item in prqlc/prqlc/src/sql/dialect.rs has a Pad::Space arm — every one falls through to the unsupported-specifier error. Confirmed by running it: select { a = (d | date.to_text "%k") } fails with PRQL doesn't support this format specifier on both sql.postgres and sql.mysql. Whether the fix is to drop the row or to add space-padding support to the dialect handlers needs a maintainer call, so it's not folded in here.
Sweep of every specifier in the table against `sql.postgres`
%k is the only failing row; the other 27 all compile:
%Y TO_CHAR(d, 'YYYY') %H TO_CHAR(d, 'HH24')
%y TO_CHAR(d, 'YY') %k ERROR — unsupported
%m TO_CHAR(d, 'MM') %I TO_CHAR(d, 'HH12')
%-m TO_CHAR(d, 'FMMM') %p TO_CHAR(d, 'AM')
%b TO_CHAR(d, 'Mon') %M TO_CHAR(d, 'MI')
%B TO_CHAR(d, 'FMMonth') %S TO_CHAR(d, 'SS')
%d TO_CHAR(d, 'DD') %f TO_CHAR(d, 'US')
%-d TO_CHAR(d, 'FMDD') %R TO_CHAR(d, 'HH24:MI')
%a TO_CHAR(d, 'Dy') %T TO_CHAR(d, 'HH24:MI:SS')
%A TO_CHAR(d, 'FMDay') %X TO_CHAR(d, 'HH24:MI:SS')
%D TO_CHAR(d, 'MM/DD/YY') %r TO_CHAR(d, 'HH12:MI:SS AM')
%x TO_CHAR(d, 'MM/DD/YY') %+ TO_CHAR(d, 'YYYY-MM-DD"T"HH24:MI:SS.USZ')
%F TO_CHAR(d, 'YYYY-MM-DD') %t %n %% literals
|
Reproduced the Keeping this PR to the one-line |
The
%-drow in the date-specifier table shows its example as` 8`— space-padded — but%-dmaps toItem::Numeric(Numeric::Day, Pad::None)inprqlc/prqlc/src/sql/dialect.rs, i.e. no padding at all. Space-padding is what%k(and chrono's%_d) does, and the table already documents%kseparately as "space-padded". The neighbouring%-mrow correctly shows7with no leading space.Docs-only, so there's no test to add. Found during the nightly survey of
web/book/src/reference/stdlib/date.md.