Skip to content

value_numeric support for scientific notation #381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

crosschainer
Copy link
Contributor

@crosschainer crosschainer commented May 12, 2025

Description

value_numeric support for scientific notation

Type of change

  •  Enhancement (simplifying, beautifying, better performance, etc.)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (change that requires code adjustments in other places)
  •  Fork needed (fix or feature that requires a resync of blockchain state)

Checklist

  • I have performed a self-review of my own code
  • I have tested this change in my development environment.
  • I have added tests to prove that this change works
  • All existing tests pass after this change
  • I have added / updated documentation related to this change

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR enhances the handling of numeric values by extending support to scientific notation in the value_numeric column.

  • Updated the regex pattern for value_numeric to include scientific notation syntax.
  • Adjusted the SQL column definition formatting.

inline comment

Co-authored-by: Copilot <[email protected]>
@crosschainer crosschainer requested a review from Copilot May 12, 2025 06:21
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug by enabling support for numeric values expressed in scientific notation in the value_numeric column.

  • Updates the regex pattern to include scientific notation (e.g., 1e10, -2.5E-3)
  • Adds a clarifying inline comment and adjusts the SQL syntax ending with a semicolon
Comments suppressed due to low confidence (1)

src/xian/services/bds/sql.py:49

  • The updated regex correctly introduces support for scientific notation; please verify that you have adequate tests covering edge cases (e.g., negative numbers, various exponent formats) to ensure reliable behavior.
WHEN value::text ~ '^"*-?[0-9]+(\.[0-9]+)?([eE][+-]?[0-9]+)?"*$'

@crosschainer crosschainer requested a review from Copilot May 12, 2025 06:31
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug by updating the regular expressions used to generate value_numeric, ensuring that numerical values in scientific notation are now correctly recognized.

  • Updated regex patterns in both create_state and create_state_changes to support scientific notation.
  • Added an inline comment to clarify the regex logic for scientific notation.
Comments suppressed due to low confidence (2)

src/xian/services/bds/sql.py:30

  • It would be beneficial to add tests covering various numeric formats including scientific notation, decimals, and negative values to ensure the regex behaves as expected.
THEN (trim(both '"' from value::text))::NUMERIC

src/xian/services/bds/sql.py:49

  • The updated regex now supports scientific notation, but please verify it correctly handles edge cases such as numbers without a fractional part or exponent properly.
WHEN value::text ~ '^"*-?[0-9]+(\.[0-9]+)?([eE][+-]?[0-9]+)?"*$'

@crosschainer crosschainer requested a review from Copilot May 12, 2025 06:34
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a bug in the numeric value conversion by enhancing the regular expression used for value_numeric to support scientific notation. Key changes include updating the regex pattern in two functions and adding inline comments documenting supported numeric formats.

Comments suppressed due to low confidence (2)

src/xian/services/bds/sql.py:51

  • Consider adding test cases to validate the new scientific notation support for various valid and invalid numeric inputs, ensuring all edge cases are covered.
WHEN value::text ~ '^"*-?[0-9]+(\.[0-9]+)?([eE][+-]?[0-9]+)?"*$'

src/xian/services/bds/sql.py:51

  • Ensure the updated regex pattern accurately handles all expected scientific notation formats, including edge cases like inputs without a decimal point or with negative exponents.
WHEN value::text ~ '^"*-?[0-9]+(\.[0-9]+)?([eE][+-]?[0-9]+)?"*$'

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