long2ice / asyncmy

A fast asyncio MySQL/MariaDB driver with replication protocol support
https://github.com/long2ice/asyncmy
Apache License 2.0
250 stars 29 forks source link

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

Closed zzzeek closed 1 year ago

zzzeek commented 1 year ago

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.

casparwylie commented 1 year ago

Any updates on this?

long2ice commented 1 year ago

fixed