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

[BUG]: select with "drizzle-orm/prisma/mysql" #4291

Open
1 task done
amaurycoudr opened this issue Mar 20, 2025 · 0 comments
Open
1 task done

[BUG]: select with "drizzle-orm/prisma/mysql" #4291

amaurycoudr opened this issue Mar 20, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@amaurycoudr
Copy link

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

0.40.1

What version of drizzle-kit are you using?

not related

Other packages

No response

Describe the Bug

What is the undesired behavior?
When using Drizzle Prisma with select statements, field renaming does not work correctly when selecting multiple fields with the same name (e.g., id from different relations). Instead of returning the renamed fields, only one field is returned, leading to data loss.

What are the steps to reproduce it?

Define Prisma models where related tables contain fields with the same name (e.g., id in User and Post models).
Use Drizzle Prisma to perform a select query with renaming, attempting to distinguish fields using aliases.
Execute the query and observe the returned result.
What is the desired result?
The query should return properly renamed fields, ensuring that both userId and postId appear distinctly in the result set.

What is the actual result?
Instead of returning renamed fields (userId, postId), the response contains only one field (id), causing the loss of data from one of the tables.

Additional Information:

Database Engine: MySQL
Potentially Related to Database Driver? Possibly related to how Drizzle Prisma handles aliasing in SQL queries.
Monorepo? Yes
TypeScript Version: (5.8.2)
Runtime: Node.js (22.12)

Example of the issue :
https://github.com/amaurycoudr/prisma-drizzle-issue

@amaurycoudr amaurycoudr added the bug Something isn't working label Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant