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
It's a known issue, unrelated to count(*), but with how values are returned from MySQL/MariaDB. See the example, and the discussion in PR #9.
For some reason I'm not clear on yet, values from MySQL are always returned as an array of ASCII integers. This is why the example uses String.fromCharCode(...row.key) to convert it into a string.
This is the case for all column types, AFAICS. 😞 So if you need to use the value as a number, you'd have to do parseInt(String.fromCharCode(...row.key)).
This only happens on MySQL and not for the other RDBMSs. I tried experimenting with different character sets and collation (e.g. CREATE TABLE (...) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;), and adding charset=utf8mb4 to the connection string, but it didn't have an effect.
So to summarize, you're actually getting the correct value: [57,50,54] are the ASCII codes for 926, and you need to convert them in your script. E.g.:
exportdefaultfunction(){constresults=sql.query(db,'SELECT count(*) c FROM filled_table;');for(constrowofresults){console.log(`${String.fromCharCode(...row.c)}`);}}
Hey @clovis-maniguet, I'd prefer to keep this issue open, if you don't mind.
Even though there's a workaround for it, it should eventually be fixed. We just haven't had the bandwidth to look into it in more depth, but any help is greatly appreciated.
Versions
What
On table of 926 rows named
filled_table
;SELECT *
SELECT count
SELECT TABLE_ROWS
Observation
Logging the response of both
SELECT count(*)
andSELECT TABLE_ROWS
show us the same responses.The text was updated successfully, but these errors were encountered: