olivierphi / Node-DBI

A SQL database abstraction layer strongly inspired by the PHP Zend Framework Zend_Db API, with support of multiple Node.js database engines
https://github.com/DrBenton/Node-DBI
93 stars 22 forks source link

binding issue with int #10

Closed hampsterx closed 10 years ago

hampsterx commented 12 years ago

fetchRow("SELECT * FROM user WHERE username = ?", ['3300'], function(err, result) {

This code is not working for me, I suspect the bind value is being converted to an integer even though the field is character varying.

Database Driver: PG

PS Is there a way I can debug to see the generated SQL?

Cheers,

TiM

olivierphi commented 12 years ago

Hi !

For tests purposes you can see DBSelect genererated SQL by addind a simple console.log('generated SQL:', sql) in "lib/dbSelect.js", at the end of the "DBSelect.prototype.assemble()" method, line 387.

About your binding issue : this is because the Pg adpater escape policy is based on isNaN(), and a test with isNaN('3300') says that '3300' is a Number. I'll try to fix it soon.

Thanks for the bug report !

olivierphi commented 10 years ago

Fixed in b044b140bded47a7dad14e446d3e7709abc57c8a. @hampsterx Thank you very much for the bug report!