Skip to content

Conversation

mewim
Copy link
Member

@mewim mewim commented May 13, 2025

Description

The current check for PreparedStatement object for WASM is too strong. In some minified build process, it can cause errors, because the constructor name is shotened and the PreparedStatement class name is no longer kept, causing the check to fail despite the object is valid.

@mewim mewim requested a review from Copilot May 13, 2025 03:55
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR relaxes the validation of WASM PreparedStatement objects and parameter objects to avoid failures in minified builds.

  • Updated the test for parameter validation to use null instead of a non-plain object.
  • Modified error messages and validation logic for both preparedStatement and params in the connection implementation.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tools/wasm/test/test_connection.js Updated the test case to expect a null parameter and a modified error message.
tools/wasm/src_js/sync/connection.js Relaxed the preparedStatement type check and updated the error messages and parameter validation.
Comments suppressed due to low confidence (1)

tools/wasm/test/test_connection.js:104

  • [nitpick] Consider adding tests for other invalid parameter types (e.g., non-object truthy values) to ensure that the validation logic in the connection always behaves as expected.
await conn.execute(preparedStatement, null);

Comment on lines 127 to 130
if (!preparedStatement ||
typeof preparedStatement !== "object" ||
preparedStatement.constructor.name !== "PreparedStatement" ||
preparedStatement._isClosed) {
throw new Error("preparedStatement must be a valid PreparedStatement object.");
throw new Error("preparedStatement is not valid or is closed.");
}
Copy link
Preview

Copilot AI May 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The error message for an invalid or closed PreparedStatement is now combined; consider splitting the checks for a more granular error message to make debugging easier.

Copilot uses AI. Check for mistakes.

@mewim mewim merged commit a9a3ade into master May 13, 2025
6 of 14 checks passed
@mewim mewim deleted the wasm-ease-type branch May 13, 2025 04:02
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 this pull request may close these issues.

1 participant