Repository navigation
Description
π Reproduction steps
- Table with a
floatcolumnf(Postgres adapter). POST β¦/rowswith{"data": {"f": 1234567.123456789}}.- Read the row (or
SELECT f FROM β¦in Postgres).
π Expected behavior
f = 1234567.123456789 β a double precision column holds 15β17 significant digits.
π Actual Behavior
f = 1234567.1234568, both in the API response and in the stored column. Every float is cut to 14 significant digits on write:
| Written | Stored / returned |
|---|---|
0.30000000000000004 |
0.3 |
1/3 |
0.33333333333333 |
2.718281828459045 |
2.718281828459 |
52.52000812345678 |
52.520008123457 |
123456789012345 |
123456789012340 |
9007199254740992 |
9007199254741000 |
99999999999999.98 |
100000000000000 |
1.7976931348623157e308 |
1.7976931348623e+308 |
point [13.404954123456789, 52.520008123456789] |
[13.404954123457, 52.520008123457] |
The same happens with updateRow, createRows, upsertRows, transactions, and after any later update of another column of the row (the whole row is re-written). A value computed in SQL by an operator (divide 3) is also truncated as soon as the row is written again. Float arrays keep full precision (they are stored as JSON). Two runs, identical results.
Cause: the Postgres adapter binds double values with PDO::PARAM_STR (Adapter/Postgres.php L1978βL1986, used e.g. in createDocument() L1036βL1046), so PHP converts the float to a string using the precision ini setting, which is 14 in the Appwrite image (php -r 'echo ini_get("precision");' β 14). There is a helper getFloatPrecision() (%.17F, SQL.php L43βL46), but the write paths do not use it. Query filter values are rounded the same way (equal 1234567.123456789 matches the stored 1234567.1234568, greaterThan 1234567.12345678 does not match it), so equality filters keep working, but range filters near the cut-off do not behave as written. utopia-php/database main still binds doubles this way.
Consequences: integers above ~10^14 kept in float columns change (123456789012345 β 123456789012340), values that clients compare exactly (e.g. after a round trip through another system) no longer match. For typical coordinates or money amounts the loss is below the 12th decimal and harmless.
π² Appwrite version
2.3.0 (utopia-php/database 7.3.11)
π» Operating system
Linux (Debian 12), Docker
π§± Your Environment
Self-hosted Appwrite 2.3.0, Postgres adapter (PostgreSQL 18).
π‘ Suggested fix
Bind floats with a round-trip-safe representation on all write paths (e.g. getFloatPrecision() / var_export-style with serialize_precision = -1), or set precision = 17 (or -1) in the Appwrite PHP image.
π Have you spent some time to check if this issue has been raised before?
- I checked and didn't find a similar issue
π’ Have you read the Code of Conduct?
- I have read the Code of Conduct
Activity