Skip to content

SqlString.escapeId and arrays #524

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

Closed
whoughton opened this issue Jun 24, 2013 · 3 comments
Closed

SqlString.escapeId and arrays #524

whoughton opened this issue Jun 24, 2013 · 3 comments

Comments

@whoughton
Copy link
Contributor

I've noticed that SqlString.escapeId does not work with arrays. I'd like to do something like:

SqlString.format(
    'SELECT ?? FROM ?? WHERE ??=? ORDER BY ?? DESC LIMIT ?',
    [['id', 'name', 'url', 'type', 'industry', 'description'], 'companies', 'name', 'TestCo', 'id', 1]
)

to produce:

SELECT `id`, `name`, `url`, `type`, `industry`, `description`
FROM `companies`
WHERE `name`='TestCo'
ORDER BY `id`
DESC LIMIT 1

Is there a specific reason for this, or has the need just not arisen previously?

@dresende
Copy link
Collaborator

No one needed before. I'll accept a pull request for it, maybe similar to what SqlString.escape does :)

@whoughton
Copy link
Contributor Author

Yup, I was thinking of something along those lines, though initially I didn't think it would need to support objects, just arrays and strings. Will look into it, thanks!

@ravi
Copy link

ravi commented Jul 31, 2013

JS arrays are converted to SQL tuples (by SqlString.escape()), no? Reproducing that, the above would produce: SELECT (id, name, ….) FROM …… which would be invalid SQL syntax (for more than one column), I think?

dveeden pushed a commit to dveeden/mysql that referenced this issue Jan 31, 2023
If CLIENT_PLUGIN_AUTH capability is not supported, no new cipher is
sent have to keep using the cipher sent in the init packet.

Fixes mysqljs#518
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants