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

possible problem with double qouted data after a named placeholder #2

Closed
danieljuhl opened this issue Nov 12, 2015 · 8 comments
Closed

Comments

@danieljuhl
Copy link

I've tried to create the most minimal case, where this happens (used with node-mysql2):

conn.execute('SELECT * FROM items WHERE id = :id AND deleted = "0000-00-00 00:00:00";', { id: Number(id) }) fails, but conn.execute('SELECT * FROM items WHERE deleted = "0000-00-00 00:00:00" AND id = :id;', { id: Number(id) }) works fine.

For some reason the first one is converted to: SELECT * FROM items WHERE id = ?";

@sidorares
Copy link
Member

what's the result of resolving named placeholders? can you print unnamed at https://github.com/sidorares/node-mysql2/blob/master/lib/connection.js#L405 ?

@sidorares
Copy link
Member

looks like a bug in named_placeholders compiler ( might be caused by "0000-00-00 00:00:00" )

@sidorares
Copy link
Member

it's ok if I delete ":" from date, so probably bug in parser in "in quote" state. Might be also the case for @mscdex node-mariasql

@danieljuhl
Copy link
Author

Seems very likely... but it depends on, whether it is placed before or after the other named placeholders (also for more complex queries - as long as the fixed date is before any named placeholders, there is no problem)

@danieljuhl
Copy link
Author

@sidorares you still want unnamed?

@sidorares
Copy link
Member

no, no need, run it locally myself

@danieljuhl
Copy link
Author

Perfect - let me know, if there is anything I can do.

As said, the workaround is simply to place the date string part prior to any named placeholders, so everything works right now, but we should try to find a way to handle this in the module.

@sidorares
Copy link
Member

it's definitely a bug, I'll try to fix it

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