Skip to content

Preserve scientific literals with positive exponent signs - #909

Open
Eric3-jp wants to merge 1 commit into
andialbrecht:masterfrom
Eric3-jp:fix-positive-exponent-literals
Open

Eric3-jp wants to merge 1 commit into
andialbrecht:masterfrom
Eric3-jp:fix-positive-exponent-literals

Conversation

@Eric3-jp

Copy link
Copy Markdown

Scientific notation with an explicit positive exponent is split into separate tokens: formatting SELECT 1e+3*2 with use_space_around_operators=True produces SELECT 1e + 3 * 2, changing the SQL.

Allow either sign in the exponent part of the existing numeric-literal rule. Parsing tests cover uppercase/lowercase exponent markers, integer/decimal mantissas, and negative values; formatting tests verify that the exponent stays intact while the multiplication operator receives spaces.

  • Regression tests added: all 8 new cases failed before the lexer change; 4 existing scientific-number controls passed.
  • Ordinary test suite on Python 3.11.16: 506 passed, 2 xfailed, 1 xpassed. The dedicated DoS-prevention suite and the maximum-recursion regression were excluded.
  • ruff check sqlparse/ and git diff --check passed.
  • Reviewed documentation impact; this corrects existing numeric-literal support without adding an option.

Prepared with OpenAI Codex assistance for implementation, tests, and review.

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