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

Providing null as a value to a query causes an error #167

Closed
Jiralite opened this issue Aug 20, 2021 · 3 comments
Closed

Providing null as a value to a query causes an error #167

Jiralite opened this issue Aug 20, 2021 · 3 comments

Comments

@Jiralite
Copy link
Contributor

Jiralite commented Aug 20, 2021

Problem

Hiya, I migrated from another package to this one (this looks great by the way) and found some peculiar behaviour. My query is like this:

<Pool>.query("UPDATE `table` SET `column` = ?;", null);

This would set the column to null. However, it doesn't work and I receive this:

{
  text: "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '?' at line 1",
  sql: 'UPDATE `table` SET `column` = ?; - parameters:[]',
  fatal: false,
  errno: 1064,
  sqlState: '42000',
  code: 'ER_PARSE_ERROR'
}

The documentation states that values is an array or an object but in the case of one placeholder, it can be given as is. In this case, I gave it as is, and it failed.

It seems to only happen with null. I assume this is a bug but a low priority one? This is fixed if I simply provide an array with null in it. Alas, here is my issue, please enlighten me if this is a bug or not!

Versions

  • Node.js: 16.6.1
  • mariadb: 2.5.4
@Jiralite Jiralite changed the title Providing null as a value to a query does nothing Providing null as a value to a query causes an error Aug 20, 2021
@rusher
Copy link
Collaborator

rusher commented Aug 23, 2021

This is clearly a bug.
null must here be considered as a value.
I've created https://jira.mariadb.org/browse/CONJS-173 for that

@Jiralite
Copy link
Contributor Author

Jiralite commented Aug 26, 2021

Thank you for confirming & triaging the issue!

@rusher
Copy link
Collaborator

rusher commented Sep 15, 2021

corrected with 016ef46.
Will be available in 2.5.5 and 3.0.1-RC

@rusher rusher closed this as completed Sep 15, 2021
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

2 participants