Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Query doesn't work with .stream() if options not exists #6028

Open
gabolera opened this issue Mar 7, 2024 · 3 comments · May be fixed by #6040
Open

Query doesn't work with .stream() if options not exists #6028

gabolera opened this issue Mar 7, 2024 · 3 comments · May be fixed by #6040

Comments

@gabolera
Copy link

gabolera commented Mar 7, 2024

Environment

Knex version: 3.1.0
Database + version: Oracle 18c
OS: Windows (WSL Ubuntu 22.04)

Bug

  1. On make a query using stream method the knex force me passing a parameter in options!

Example: (with first case, never join .on('data'))

// This dosen't work
const stream = db.raw(`select * from users`).stream()

stream.on('data', (chunk) => {
  console.log(chunk)
})



// But... This work
const stream = db.raw(`select * from users`).stream({})

stream.on('data', (chunk) => {
  console.log(chunk)
})

If is optional parameters is should not a impeditive for use .pipe() .on()

@rluvaton
Copy link
Member

rluvaton commented Mar 16, 2024

Can you create a pr to fix this?

@gabolera
Copy link
Author

Shure 🙂

gabolera added a commit to gabolera/knex that referenced this issue Mar 20, 2024
@gabolera
Copy link
Author

Finished tests, and okay for oracledb driver (PR #6040) but a question arose here.

In this case i solved only for oracledb driver! I see example used on mysql

_stream(connection, obj, stream, options) {
if (!obj.sql) throw new Error('The query is empty');
options = options || {};

But maybe it's interesting fix this on here where stream options is {} with default for all drivers?

knex/lib/client.js

Lines 157 to 160 in aedba5e

stream(connection, queryParam, stream, options) {
const queryObject = enrichQueryObject(connection, queryParam, this);
return this._stream(connection, queryObject, stream, options);
}

stream(connection, queryParam, stream, options = {}) {

or this is a bad idea?

Thanks :) @rluvaton

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

Successfully merging a pull request may close this issue.

2 participants