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

execlastid doesn't respect support_big_numbers #22

Open
yshrsmz opened this issue Mar 4, 2024 · 1 comment · May be fixed by #23
Open

execlastid doesn't respect support_big_numbers #22

yshrsmz opened this issue Mar 4, 2024 · 1 comment · May be fixed by #23

Comments

@yshrsmz
Copy link
Contributor

yshrsmz commented Mar 4, 2024

related: #13, #15

export async function createAuthorReturnId(client: Client, args: CreateAuthorReturnIdArgs): Promise<number> {
const [result] = await client.query<ResultSetHeader>({
sql: createAuthorReturnIdQuery,
values: [args.name, args.bio]
});
return result?.insertId ?? 0;
}

This method should return string as support_big_numbers and big_number_strings is enabled in sqlc.dev.yml

- schema: "authors/mysql/schema.sql"
queries: "authors/mysql/query.sql"
engine: "mysql"
codegen:
- plugin: ts
out: node-mysql2/src/db
options:
runtime: node
driver: mysql2
mysql2:
big_number_strings: true
support_big_numbers: true

This is because I explicitly declared a return type as number here

https://github.com/sqlc-dev/sqlc-gen-typescript/pull/13/files#diff-2078b150759ca61c4ae2bb37cb070f5a2d81e64c7b4d1aa126f621e2520f13d0R641-R643

but should respect PK's type.

@yshrsmz
Copy link
Contributor Author

yshrsmz commented Mar 4, 2024

@kyleconroy How can I find out PK's type?
I checked every value in GenerateRequest, but could not find one.

AFAIK, we can return Promise<string | number> from :execlastid, but it's not possible to define explicit type with current information.

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 a pull request may close this issue.

1 participant