Skip to content

query.sql unformatted until query sent to connection #984

Open
@layerzerolabs

Description

@layerzerolabs

Hi,

In the Readme it says that after running a prepared statement you can get the full SQL with query.sql. However I am finding that it returns the string from the prepared statement directly, containing the question mark, rather than replacing it with the parameters.

Regards

Naomi

Activity

dougwilson

dougwilson commented on Feb 1, 2015

@dougwilson
Member

Can you show me an example of what you are doing, please? This library doesn't support prepared statements, though it does support doing replacements that look similar to them.

layerzerolabs

layerzerolabs commented on Feb 1, 2015

@layerzerolabs
Author

Wow, quick reply! I'm using that cool thing where you can insert a full object. Here's the relevant code:

var query = pool.query('insert into todmorden set ?', reading, callback);
console.log(query.sql);

The insert works perfectly, inserting a row with all the fields from the reading object. However what gets logged to the console is "insert into todmorden set ?"

It doesn't affect the functionality, but just makes it harder to debug.

layerzerolabs

layerzerolabs commented on Feb 1, 2015

@layerzerolabs
Author

Sorry, didn't mean to close the issue! Butter fingers!

dougwilson

dougwilson commented on Feb 1, 2015

@dougwilson
Member

Ah. It's possible it's an issue with using pool.query vs connection.query. If you can before I get to it, let me know if connection.query works or not.

self-assigned this
on Feb 1, 2015
dougwilson

dougwilson commented on Feb 1, 2015

@dougwilson
Member

Ok, I see the issue: query.sql is not actually transformed until the query is sent to the database. We may want to actually transform it right away.

changed the title [-]query.sql returns question mark[/-] [+]query.sql unformatted until query sent to connection[/+] on Feb 1, 2015

14 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

    Development

    Participants

    @dougwilson@maligree@layerzerolabs@Telokis@xiaolintangyuan

    Issue actions

      query.sql unformatted until query sent to connection · Issue #984 · mysqljs/mysql