Not all rows are returned when encountering an empty string in the first column
NeKzor opened this issue ยท 4 comments
What a waste of time this was to debug just to find out that this library cannot handle simple select queries. The current workaround is to select another column that cannot contain an empty string before the column that could contain an empty string. This is a big problem when you select large amounts of data from a table and nobody would notice that the data is incomplete! I actually wonder now where the issue is...
Minimal reproducible example:
const rows = await db.query(`select '' as a`);
console.log(rows);
Actual output:
INFO connecting 127.0.0.1:3307
INFO connected to 127.0.0.1:3307
[]
INFO close connection
Here is a working example with npm:mysql2/promise
:
const [rows] = await db.query(`select '' as a`);
console.log(rows);
Expected output:
[ { a: "" } ]
Used Deno version:
deno 1.36.4 (release, x86_64-unknown-linux-gnu)
v8 11.6.189.12
typescript 5.1.6
Used database images from Docker Hub:
- mariadb:11.1
- mariadb:11
- mariadb:10
- mysql:8
- mysql:5
Oh wow, it looks like this is a regression caused by e3359d0 (PR #140).
CC @shiyuhang0 @lideming
Thanks for the really fast fix! It's working again in v2.12.1.
Sorry for the mistake. I think mysql/mariadb may not following the https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_ok_packet.html.
I also see the replacement of eof is not that easy in go-sql-driver/mysql#1153