Skip to content

GH-1311: Use Locale.ROOT when formatting JDBC interval strings - #1312

Open
Arawoof06 wants to merge 1 commit into
apache:mainfrom
Arawoof06:interval-string-locale-root
Open

Arawoof06 wants to merge 1 commit into
apache:mainfrom
Arawoof06:interval-string-locale-root

Conversation

@Arawoof06

Copy link
Copy Markdown
Contributor

What's Changed

formatIntervalYear and formatIntervalDay build the Oracle-style interval strings the JDBC interval accessor returns from getString()/getObject() with String.format and no explicit locale, so java.util.Formatter renders the %d digits using the JVM default locale. On a JVM whose default locale uses non-ASCII digits (ar-EG, bn-BD, mr-IN, ...) an interval comes back as +٠٢١-٠٢ instead of +021-02, which corrupts the value handed to JDBC clients and breaks anything parsing it as ASCII. Pass Locale.ROOT to both calls, the same fix GH-1300 applied to the C Data Interface format strings.

Closes #1311.

@github-actions

This comment has been minimized.

@lidavidm lidavidm added the bug-fix PRs that fix a big. label Oct 1, 2026
@github-actions github-actions Bot added this to the 20.0.0 milestone Oct 1, 2026

@jbonofre jbonofre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

Using Locale.ROOT in formatInternalYear and formatIntervalDay is the right fix, since %d otherwise follows the default locale and can emit non-ASCII digits (e.g. ar-EG). The new test covers that case, and the expected values (+021-02, +001 18:25:16.766) check out.

Nit (non blocking): testFormatIntervalIgnoresDefaultLocale calls Locale.setDefault, which is JVM-global. It restores the locale in finally, so this is only a concern if JUnit parallel execution is enabled for this module. If it is, consider @ResourceLock(Resources.LOCALE).

@jbonofre
jbonofre force-pushed the interval-string-locale-root branch from 404213c to f63a207 Compare October 2, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix PRs that fix a big.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flight SQL JDBC interval strings use the default locale for digits [C Data] Format.asString emits locale dependent digits in format strings

3 participants