and this code results in the following node-mysql2 error
{
code: 'ER_PARSE_ERROR',
errno: 1064,
sql: '-- name: FindManyByAccountId :many\nSELECT\n account_transaction_id,\n account_id,\n point_saas_account_transaction_category_id,\n tenant_account_transaction_category_id,\n history_type,\n amount,\n expired_at,\n balance,\n title,\n content,\n created_at\nFROM\n account_transactions\nWHERE\n account_id = 1\nORDER BY\n created_at DESC\nLIMIT\n \'0\', \'20\'',
sqlState: '42000',
sqlMessage: 'You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near \'\'20\', \'0\'\' at line 21'
}
So I think node-mysql2 does not respect supportBigNumbers and bigNumberStrings options here.
What I came up with is these two solution:
Somehow get which argument is used for which column/condition, and decide TypeScript type
I believe this is not possible for now (see #22 )
Loosen the BigNumber type to always string | number and let users chose the type
if both supportBigNumbers and bigNumberStrings is false/unspecified, use number in that case.
also posted to node-mysql2: https://github.com/sidorares/node-mysql2/issues/2551
As stated in the title(and the liked issue), node-mysql2 seems to always use number for limit and offset(and possibly some other cases).
And that does not work well with our current implementation.
sqlc-gen-typescript currently generates following code for the above query.
and this code results in the following node-mysql2 error
So I think node-mysql2 does not respect
supportBigNumbers
andbigNumberStrings
options here.What I came up with is these two solution:
string | number
and let users chose the typesupportBigNumbers
andbigNumberStrings
is false/unspecified, use number in that case.