Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bigNumberStrings: true is not respected for LIMIT and OFFSET #2551

Open
yshrsmz opened this issue Apr 2, 2024 · 0 comments
Open

bigNumberStrings: true is not respected for LIMIT and OFFSET #2551

yshrsmz opened this issue Apr 2, 2024 · 0 comments

Comments

@yshrsmz
Copy link

yshrsmz commented Apr 2, 2024

I have a following SQL query.

-- name: FindManyByAccountId :many
SELECT
  account_transaction_id,
  account_id,
  point_saas_account_transaction_category_id,
  tenant_account_transaction_category_id,
  history_type,
  amount,
  expired_at,
  balance,
  title,
  content,
  created_at
FROM
  account_transactions
WHERE
  account_id = ?
ORDER BY
  created_at DESC
LIMIT
  ?
OFFSET
  ?;

When I execute it, I get the error below.

const [rows] = await connection.query<RowDataPacket[]>({
    sql: findManyByAccountIdQuery,
    values: [1, '20', '0'],
    rowsAsArray: true,
  })
 { 
  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'
}

I've set both supportBigNumbers and bigNumberStrings to true, so I'm guessing those 2 options are not respected for LIMIT and OFFSET(both can be a BIGINT value).

BTW if I provide number value, it works as expected.

const [rows] = await connection.query<RowDataPacket[]>({
    sql: findManyByAccountIdQuery,
    values: [1, 20, 0],
    rowsAsArray: true,
  })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant