Skip to content

Instantly share code, notes, and snippets.

@methane
Last active February 26, 2024 13:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save methane/d383ebdb597e361b49dd0db4c36b2a93 to your computer and use it in GitHub Desktop.
Save methane/d383ebdb597e361b49dd0db4c36b2a93 to your computer and use it in GitHub Desktop.
mariadb float type
mysql> create table t (id integer primary key, f1 float, f2 float(10,4));

mysql> insert into t (id, f1, f2) values (1, 0.0001, 0.0001);

mysql> select f1, f1=0.0001, f1=0.0001e0, f2, f2=0.0001, f2=0.0001e0 from t;
+--------+-----------+-------------+--------+-----------+-------------+
| f1     | f1=0.0001 | f1=0.0001e0 | f2     | f2=0.0001 | f2=0.0001e0 |
+--------+-----------+-------------+--------+-----------+-------------+
| 0.0001 |         0 |           0 | 0.0001 |         1 |           0 |
+--------+-----------+-------------+--------+-----------+-------------+
1 row in set (0.00 sec)
@methane
Copy link
Author

methane commented Feb 26, 2024

PyMySQL/mysqlclient#705 より。
MariaDB 10.10も10.5も同じ。
文字列として比較されているのかdecimalとして比較されているのかよくわからない。
暗黙の型変換をデバッグする機能はないものか。

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