-
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?
Changes from 5 commits
f0e40e7
693e2a4
6169c7b
dd42ca9
39f4c4f
7a66f67
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,14 @@ QueryResult.prototype.nextChunk; | |
*/ | ||
QueryResult.prototype.nextIpcBuffer; | ||
|
||
/** | ||
* Function to return logical types for columns | ||
* | ||
* @method | ||
* @return {ColumnInfo[]} - Array of column names and types | ||
*/ | ||
QueryResult.prototype.columns; | ||
|
||
/** | ||
* @name asyncIterator | ||
* @memberof module:duckdb~QueryResult | ||
|
@@ -218,12 +226,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 commentThe reason will be displayed to describe this comment to others. Learn more. Description of change: The old version used AsyncIterator (function was marked with Thanks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What problem does this solve? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It started to return Example to demo that ❯ 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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The biggest problem that, old variant is an There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. |
||
const statement = new Statement(this, sql); | ||
const queryResult = await statement.stream.apply(statement, arguments); | ||
for await (const result of queryResult) { | ||
yield result; | ||
} | ||
return statement.stream.apply(statement, arguments); | ||
} | ||
|
||
/** | ||
|
@@ -713,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 commentThe reason will be displayed to describe this comment to others. Learn more. |
||
*/ | ||
Statement.prototype.columns; | ||
|
||
|
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.