Skip to content
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

sudden loss of float precision for even very low numbers of significant digits in the 0.2.7 series #56

Closed
zzzeek opened this issue Feb 15, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@zzzeek
Copy link

zzzeek commented Feb 15, 2023

occurs as of 0.2.7rc6 and possibly earlier, is not in 0.2.5

import asyncmy
import asyncio


async def main():
    conn = await asyncmy.connect(
        user="scott", password="tiger", db="test", host="localhost"
    )
    cursor = conn.cursor()

    await cursor.execute("""DROP TABLE IF EXISTS t""")

    await cursor.execute(
        """
    CREATE TABLE  t (
	scale_value DOUBLE(15, 12)
)"""
    )

    dec_value = 45.7683
    await cursor.execute(
        "INSERT INTO t (scale_value) VALUES (%s)", [dec_value]
    )

    await cursor.execute("SELECT scale_value FROM t")
    row = await cursor.fetchone()

    assert row[0] == dec_value, row[0]


asyncio.run(main())

test fails with

AssertionError: 45.768299102783

no other MySQL or database driver loses precision on only four significant digits. 0.2.5 did not have this problem and was on par with other drivers.

sqlalchemy-bot pushed a commit to sqlalchemy/sqlalchemy that referenced this issue Feb 16, 2023
asyncmy 0.2.7 has had a loss in float precision for even
very low numbers of significant digits.

Change-Id: Iec6d2650943eeaa8e854f21990f6565d73331f8c
References: long2ice/asyncmy#56
sqlalchemy-bot pushed a commit to sqlalchemy/sqlalchemy that referenced this issue Feb 27, 2023
asyncmy 0.2.7 has had a loss in float precision for even
very low numbers of significant digits.

Change-Id: Iec6d2650943eeaa8e854f21990f6565d73331f8c
References: long2ice/asyncmy#56
(cherry picked from commit 8855656)
@casparwylie
Copy link

Any updates on this?

@long2ice long2ice added the bug Something isn't working label Mar 29, 2023
@long2ice
Copy link
Owner

fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants