Skip to content

Documentation: Pool does not compute query.sql immediately #1246

Closed
@venning

Description

@venning

I just wanted to record this for posterity in case someone else runs into it. It's not a big deal, but this gave me grief for a while, until I went through the code and realized Pool is actually working as it is supposed to. It might be worth documenting this. Otherwise, feel free to close this issue.


When you run Pool#query(sqlString, values, callback) or Pool#query(options, callback), the pool does not immediately format the sql statement due to the connection being acquired asynchronously (after Pool#query returns). The following does work but not as you'd expect:

var query = pool.query('INSERT INTO items SET ?', item, cb);
console.log(query.sql); // INSERT INTO items SET ?

The sql statement will be properly formatted/escaped once the underlying connection is acquired and Connection#query is called.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions