drizzle-team / drizzle-team/drizzle-orm

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

Open
#4,291 0 comments 0 reactions 0 assignees View on GitHub
bug priority
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Report hasn't been filed before.

- [x] 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.