-
Notifications
You must be signed in to change notification settings - Fork 4
Client refactors #422
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
base: main
Are you sure you want to change the base?
Client refactors #422
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| const _rust = require("../index"); | ||
| const { convertComplexType } = require("./types/cql-utils"); | ||
|
|
||
| class PreparedInfo { | ||
| /** | ||
| * @param {Array<type>} types | ||
| * @param {string} query | ||
| * @param {Array<string>} colNames | ||
| */ | ||
| constructor(types, query, colNames) { | ||
| this.types = types; | ||
| this.query = query; | ||
| this.colNames = colNames; | ||
| } | ||
|
|
||
| /** | ||
| * @param {string} query | ||
| * @param {_rust.SessionWrapper} client | ||
| * @returns {Promise<PreparedInfo>} | ||
| */ | ||
| static async create(query, client) { | ||
| let expectedTypes = await client.prepareStatement(query); | ||
| let types = expectedTypes.map((t) => convertComplexType(t[0])); | ||
| let colNames = expectedTypes.map((t) => t[1].toLowerCase()); | ||
| return new PreparedInfo(types, query, colNames); | ||
| } | ||
| } | ||
|
|
||
| module.exports.PreparedInfo = PreparedInfo; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,10 +41,17 @@ class ResultSet { | |
| */ | ||
| #encoder; | ||
|
|
||
| /** | ||
| * Internal representation of the page state, used for fetching the next page of results. | ||
| * @type {rust.PagingStateWrapper?} | ||
| * @package | ||
| */ | ||
| innerPageState; | ||
|
|
||
| /** | ||
| * @param {rust.QueryResultWrapper} result | ||
| * @param {_Encoder} encoder | ||
| * @param {rust.PagingStateResponseWrapper} [pagingState] | ||
| * @param {rust.PagingStateWrapper} [pagingState] | ||
|
Contributor
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. ♻️ This fix should constitute a separate commit. |
||
| */ | ||
| constructor(result, encoder, pagingState) { | ||
| // Old constructor logic only for purpose of unit tests. | ||
|
|
@@ -103,6 +110,7 @@ class ResultSet { | |
| this.pageState = null; | ||
|
|
||
| if (pagingState) { | ||
| this.innerPageState = pagingState; | ||
| let rawPageState = pagingState.getRawPageState(); | ||
| this.pageState = rawPageState.toString("hex"); | ||
| Object.defineProperty(this, "rawPageState", { | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -288,26 +288,20 @@ function validateFn(fn, name) { | |||||||||||||||||||
| * If the params are passed as an associative array (Object), | ||||||||||||||||||||
| * it adapts the object into an array with the same order as columns | ||||||||||||||||||||
| * @param {Array|Object} params | ||||||||||||||||||||
| * @param {Array} columns | ||||||||||||||||||||
| * @param {PreparedInfo} columns | ||||||||||||||||||||
|
||||||||||||||||||||
| * @param {PreparedInfo} columns | |
| * @param {{ types: Array, colNames: Array }} columns |
Copilot
AI
Apr 16, 2026
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.
adaptNamedParamsPrepared() is documented to accept Array|Object params, but it now unconditionally calls toLowerCaseProperties(params) which throws for null/undefined and produces incorrect results for arrays. Either restore the early-return guard for non-object params (and empty columns) or tighten the JSDoc/type contract to match the new required inputs.
| function adaptNamedParamsPrepared(params, columns) { | |
| function adaptNamedParamsPrepared(params, columns) { | |
| if (!columns || !columns.types || columns.types.length === 0) { | |
| return params; | |
| } | |
| if (params === null || params === undefined || Array.isArray(params) || typeof params !== "object") { | |
| return params; | |
| } |
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.
exports.throwNotSupportedis assigned twice; the second assignment is redundant and makes it easier to introduce export-order bugs during future edits. Remove the duplicate export so each symbol is exported exactly once.