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

jsonArrayFrom integer foreign keys are not converted to strings but the type says string #1293

Open
Andrew-Chen-Wang opened this issue Dec 15, 2024 · 2 comments
Labels
postgres Related to PostgreSQL typescript Related to Typescript

Comments

@Andrew-Chen-Wang
Copy link

I have two Postgres tables like this:

Table A: id (auto increment)

Table B: id (auto increment), tableAFK (references Table A)

Then, I perform a select from with jsonArrayFrom:

jsonArrayFrom(
            eb.selectFrom("Table B")
              .select(["Table B.tableAFK"])
          ).as("blah")

The actual returned type is {tableAFK: number} like {tableAFK: 1} instead of {tableAFK: string} like {tableAFK: "1"}. But the typescript inferred type is correct: {tableAFK: string}, the return value is a number though.

@igalklebanov
Copy link
Member

igalklebanov commented Dec 15, 2024

Hey 👋

Can you provide a kyse.link that reproduces your issue?

@igalklebanov igalklebanov added postgres Related to PostgreSQL typescript Related to Typescript labels Dec 15, 2024
@Andrew-Chen-Wang
Copy link
Author

Hey @igalklebanov I tried recreating something minimal: https://kyse.link/HiM0D

To explain, the select from table a is returning an id of type string. The select also returns a JSON array of what I expect to also be of type string[] since the column I am selecting from is type id, and generated columns return string. Instead it actually returns number[]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
postgres Related to PostgreSQL typescript Related to Typescript
Projects
None yet
Development

No branches or pull requests

2 participants