Skip to content

Conversation

@viveknathani
Copy link

@viveknathani viveknathani commented Dec 18, 2025

Description

Adds width specifier support for %d and %i format specifiers in the printf function. This continues the support for the issue #885.

Examples:

  • Width specifiers: printf('%5d', 42) → " 42" (right-padded to 5 characters)
  • Zero-padding: printf('%05d', 42) → "00042" (zero-padded instead of spaces)
  • Precision: printf('%.3d', 42) → "042" (minimum digits)
  • Combined: printf('%5.3d', 42) → " 042" (width + precision together)

Behavior matches SQLite's printf implementation.

Motivation and context

I got interested in contributing and I saw in COMPAT.md that printf needs better support for modifiers. This felt like a good first contribution to make. It aligns with the goal of making Turso compatible with SQLite.

Description of AI Usage

Claude code helped me with a code review. It suggested eliminating code duplication by parsing width separately from format type handling.

Copy link

@turso-bot turso-bot bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please review @pereman2

@github-actions github-actions bot added the core label Dec 18, 2025
@viveknathani
Copy link
Author

hi @pereman2 - quick ping, would appreciate your thoughts when you get a chance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants