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

fix: question mark for placeholder does not work #1424

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

vanvuongngo
Copy link
Contributor

@vanvuongngo vanvuongngo commented Nov 25, 2024

fix: question mark for placeholder does not work

If I follow the example with a question mark for a placeholder then this exception is thrown.

connection.execute("delete from tb_test where id=?", ['test3']);
"[object Object]" is not one of the cases of error

or this with a try-catch

error:

(new Error("[object Object] (see error.payload)", "dist.bindings.js", 157))

error.payload:

{ tag: "query-failed", val: "Error { kind: Db, cause: Some(DbError { severity: "ERROR", parsed_severity: Some(Error), code: SqlState(E42601), message: "syntax error at end of input", detail: None, hint: None, position: Some(Original(35)), where_: None, schema: None, table: None, column: None, datatype: None, constraint: None, file: Some("scan.l"), line: Some(1240), routine: Some("scanner_yyerror") }) }" }

environment

  • spin: 3.0.0
  • macos
  • postgresql 17
  • target: wasm32-wasip1

Copy link
Contributor Author

@vanvuongngo vanvuongngo left a comment

Choose a reason for hiding this comment

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

add try-catch to get error informations

@itowlson
Copy link
Contributor

Thanks for flagging this! However, the page in question covers both MySQL and Postgres. The example in this PR is for MySQL, for which the question mark is correct. And we didn't want to clutter the page with MySQL and Postgres examples that were almost identical, so instead the paragraph above the sample links to a Postgres example.

I'll look at adding comments to the sample noting differences for Postgres.

@karthik2804 is it worth surfacing the error payload more visibly in this case, or is that part of the JS exception system and out of our control?

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.

2 participants