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

Return type of Queryable.query is wrong when query is not SELECT #321

Open
silane opened this issue Mar 18, 2024 · 0 comments
Open

Return type of Queryable.query is wrong when query is not SELECT #321

silane opened this issue Mar 18, 2024 · 0 comments

Comments

@silane
Copy link

silane commented Mar 18, 2024

query(query: SQLQuery): Promise<any[]>;

Return type of Queryable.query is declared to be Promise<any[]> but this is correct only when in SELECT query and not INSERT or DELETE or something else. When INSERT, the returned value seems to be object like follows.

ResultSetHeader {
  fieldCount: 0,
  affectedRows: 0,
  insertId: 0,
  info: "Records: 0  Duplicates: 0  Warnings: 0",
  serverStatus: 2,
  warningStatus: 0
}

I'm getting TypeScript error when reading affectedRows, but it actually works at runtime.

スクリーンショット 2024-03-19 004352

Using @databases/mysql, but may be the same for other DBs.

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

No branches or pull requests

1 participant