-
Notifications
You must be signed in to change notification settings - Fork 27
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
feat: Expose LogicalType(s) for columns in QueryResult, fix #24 #25
base: main
Are you sure you want to change the base?
Conversation
fc51bba
to
3ea861a
Compare
3ea861a
to
f0e40e7
Compare
@@ -218,12 +225,9 @@ Connection.prototype.each = function (sql) { | |||
* @param {...*} params | |||
* @yields row chunks | |||
*/ | |||
Connection.prototype.stream = async function* (sql) { | |||
Connection.prototype.stream = async function (sql) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description of change:
The old version used AsyncIterator (function was marked with *
), which will lead to the wrong return type (not QueryResult
) + unexpected iteration over another iterator.
Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What problem does this solve?
This will break the current API and require changes elsewhere that is doable but unsure if it makes sense here.
Could the GetColumns itself not be an async function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It started to return QueryResult
which is declared in typings, when the old one return AsyncGenerator
.
It's not possible to call getColumns
on top of AsyncIterator
.
Example to demo that async *
returns AsyncGenerator.
❯ node
Welcome to Node.js v16.19.1.
Type ".help" for more information.
> class MyClass { kek() { return true }; };
undefined
> const fn = async function* () { return new MyClass(); }
undefined
> console.log(fn())
Object [AsyncGenerator] {}
undefined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the current version returns a class wrapping an AsyncGenerator.
Something like:
class MyClass {
someSyncMethod() {
return 0;
}
async someAsyncMethod() {
await setTimeout(1);
return 42;
}
async *[Symbol.asyncIterator]() {
for (var i = 0; i<10; i++)
yield i;
}
};
An instance of this class can behave like an async generator (so var c = new MyClass; for await (var obj of c) ...
, but can also have methods of its own like c.someSyncMethod()
or await c.someAsyncMethod()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The biggest problem that, old variant is an AsyncGenerator
on top of QueryResult
(local scoped), which implements asyncIterator
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure I see the problem as you are seeing it, could you go over it once again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps it would be better do something similar to the Line 588 in 2722553
if you were to use the |
@@ -717,7 +718,7 @@ Statement.prototype.sql; | |||
|
|||
/** | |||
* @method | |||
* @return {ColumnInfo[]} - Array of column names and types | |||
* @return {ColumnInfo[] | null} - Array of column names and types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -262,7 +262,7 @@ export class Statement { | |||
|
|||
run(...args: [...any, Callback<void>] | any[]): Statement; | |||
|
|||
columns(): ColumnInfo[]; | |||
columns(): ColumnInfo[] | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello!
Fix - #24
Thanks