brianc / node-libpq

Simple, low level native bindings to PostgreSQL's libpq from node.js
111 stars 41 forks source link

Pass paramFormats and paramLengths onto libpq #56

Open danielgavrilov opened 6 years ago

danielgavrilov commented 6 years ago

Similar to #52, this passes paramFormats and paramLengths onto libpq, except the parameters are constructed in JavaScript. Includes more extensive tests.

Would be happy to add the tests onto #52 if that approach is preferred.

The intent is to fix an inconsistency in node-postgres, where non-native bindings pass buffers as binary parameters, but native bindings (using this library) pass them as strings. Passing paramFormats and paramLengths is currently enough to fix this—if these are passed, libpq correctly detects them as binary parameters (see PostgreSQL fe-exec.c).

Thanks for looking into this!