Skip to content

Fix one-to-one relation for MySQL versions which do not support LIMIT parameter #4557

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mdevils
Copy link

@mdevils mdevils commented May 23, 2025

Hello Drizzle team,

This might look like a strange fix to you, so I'm open for a discussion.

We are using Drizzle ORM for Atlassian Forge SQL (https://developer.atlassian.com/platform/forge/storage-reference/sql/) which is based on TiDB database.

With help of forge-sql-orm project we managed to make the Drizzle ORM work in our case, though we had to hack and change mode of query builders from default to planetscale.

Now we faced an issue with relations. The thing is that TiDB doesn't support LIMIT parameters/substitutions. So basically LIMIT ? throws a parse error. Therefore we have to wrap numbers into sql.raw when we call limit/offset methods in select or pass limit/offset to query builders.

The issue is that the query builder has 1 hardcoded and we can't modify it from our code.

This fix works for our case, though it's not at all elegant. Maybe a different mode will be needed to support Forge SQL.

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 this pull request may close these issues.

2 participants