Skip to content
This repository has been archived by the owner on Dec 27, 2019. It is now read-only.

Should work with a QueryConfig #23

Open
abenhamdine opened this issue Mar 1, 2017 · 2 comments
Open

Should work with a QueryConfig #23

abenhamdine opened this issue Mar 1, 2017 · 2 comments

Comments

@abenhamdine
Copy link
Contributor

abenhamdine commented Mar 1, 2017

Hi Brianc, and thx for this great module !

Unlike pg.Client, QueryStream doesn't seem to work when a QueryConfig is passed, ie an object as :

{
    text : 'SELECT * FROM foo WHERE bar =$1,
    values : [1]
}

I get the following error :

Unhandled rejection TypeError: "string" must be a string, Buffer, or ArrayBuffer
    at Function.byteLength (buffer.js:363:11)
    at module.exports.Writer.addCString (C:\node-projects\payroll-app\node_modules\buffer-writer\index.js:57:22)
    at Connection.parse (C:\node-projects\payroll-app\node_modules\pg\lib\connection.js:212:6)
    at module.exports.Cursor.submit (C:\node-projects\payroll-app\node_modules\pg-query-stream\node_modules\pg-cursor\index.js:21:7)
    at Client._pulseQueryQueue (C:\node-projects\payroll-app\node_modules\pg\lib\client.js:298:24)
    at Client.query (C:\node-projects\payroll-app\node_modules\pg\lib\client.js:326:8)

Is it a bug or a this feature is missing ?

Thx by advance.

@brianc
Copy link
Owner

brianc commented Aug 7, 2017

It's just a missing feature. :/ I need to support that, just haven't had the time yet.

@q42jaap
Copy link

q42jaap commented Mar 7, 2019

I'm using sql-template in my source code which is really nice, so having this feature would be a big bonus. As a workaround I'm currently using:

  const {text, values} = SQL`
      SELECT
        event_id,
        user_id,
        data->>'sessionDateTime' AS session_date_time,
        data
      FROM event
      WHERE data->>'sessionDateTime' >= ${beginDateTime}
        AND data->>'sessionDateTime' <= ${endDateTime}
    `;
  const query = new QueryStream(text, values)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants