GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Loss of scale when reading numeric with zero value · Issue #53 · FirebirdSQL/python3-driver

Loss of scale when reading numeric with zero value #53

New issue
Copy link
New issue
Copy link
Closed
Closed
Loss of scale when reading numeric with zero value#53
Copy link

Description

@qweqq
qweqq
opened on Jul 25, 2025
Issue body actions

Hello!

When reading a numeric column with zero value the scale of the numeric value is not preserved:

import firebird.driver as firebird
import decimal

con = firebird.connect('employee')
cur = con.cursor()
cur.execute("select cast('0.00' as NUMERIC(9,2)) from rdb$database")

val_from_db = cur.fetchone()[0]
val_from_py = decimal.Decimal('0.00')

val_from_db_str = format(val_from_db, 'f')
val_from_py_str = format(val_from_py, 'f')

print(val_from_db_str)
print(val_from_py_str)

assert val_from_db_str == val_from_py_str

cur.close()
con.close()

Output:

0
0.00
Traceback (most recent call last):
  File "/home/qweqq/test3.py", line 17, in <module>
    assert val_from_db_str == val_from_py_str

While investigating the issue I found that a python decimal.Decimal with zero value divided by anything does not change its scale:

import decimal
print(format(decimal.Decimal('0') / 1000, 'f'))

Output:

0

but if the zero value is scaled using the builtin scaleb method it works:

import decimal
print(format(decimal.Decimal('0').scaleb(-3), 'f'))

Output:

0.000

Regards,

Activity

  1. qweqq
    added 2 commits that reference this issue on Jul 25, 2025

    fix FirebirdSQL#53 Loss of scale when reading numeric with zero value

    This issue will close once commit 5a71600 is merged into the 'master' branch.
    5a71600

    fix FirebirdSQL#53 Loss of scale when reading numeric with zero value

    This issue will close once commit 2b7040a is merged into the 'master' branch.
    2b7040a
  2. pcisar
    closed this as completedin 2b7040aon Jul 26, 2025
  3. pcisar
    added a commit that references this issue on Jul 26, 2025

    Merge pull request #54 from qweqq/patch-2

    This issue will close once commit 2ed1050 is merged into the 'master' branch.
    2ed1050
  4. pcisar commented on Jul 26, 2025

    @pcisar
    pcisar
    on Jul 26, 2025
    Contributor
    More actions

    @qweqq Thanks

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.