You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Raw value (database/sql): -6279.927, Type: float32
Value from Bun (mysqldialect): -6279.930176
if now update var positionXWithBun float64
Raw value (database/sql): -6279.927, Type: float32
Value from Bun (mysqldialect): -6279.930176
work
mysql> SELECT CAST(position_x AS DOUBLE) AS precise_value FROM characters WHERE guid = 1;
+------------------+
| precise_value |
+------------------+
| -6279.9267578125 |
+------------------+
1 row inset (0.02 sec)
mysql> SELECT position_x FROM characters WHERE guid = 1;
+------------+
| position_x |
+------------+
| -6279.93 |
+------------+
1 row inset (0.01 sec)
mysql> SELECT VERSION();
+-----------+
|VERSION() |
+-----------+
| 8.0.40 |
+-----------+
1 row inset (0.01 sec)
mysql> DESCRIBE characters position_x;
+------------+-------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+-------+------+-----+---------+-------+
| position_x | float | NO || 0 ||
+------------+-------+------+-----+---------+-------+
1 row inset (0.03 sec)
go list -m github.com/go-sql-driver/mysql
github.com/go-sql-driver/mysql v1.8.1
go list -m github.com/uptrace/bun/dialect/mysqldialect
github.com/uptrace/bun/dialect/mysqldialect v1.2.6
When using Bun with MySQL and a column of type
FLOAT
, thedatabase/sql
driver correctly returns a value of typefloat32
. However, Bun fails to scan this value into a Go struct field of typefloat32
with the following error:My code: https://github.com/WarhoopAll/Grimoire/blob/28c38ff89bdaa980ea1618c7e8802e3f991db6ca/app/model/character.go#L23
To Reproduce
Create a MySQL table with a
FLOAT
column:Fast sctipt for test
okey check code
bun/schema/scan.go
Line 41 in 014b142
reflect.Float32: scanFloat64
there is no conversion of float32 to float64
add case
work fine:
Old issue
#993
The text was updated successfully, but these errors were encountered: