-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Open
Labels
bugSomething isn't workingSomething isn't working
Description
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.44.5
What version of drizzle-kit
are you using?
0.31.4
Other packages
bun@1.2.22
Describe the Bug
I am trying to set up Drizzle using bun-sql to connect to MySQL. Unfortunately it seems like the SQL it generates is "postgres" style so it errors when MySQL tries to execute it.
Here's some code:
import { drizzle } from 'drizzle-orm/bun-sql';
import { SQL } from 'bun';
import schema from './schema';
const client = new SQL({
adapter: 'mysql',
database: process.env.DB_NAME,
hostname: process.env.DB_HOST,
password: process.env.DB_PASSWORD,
port: Number.parseInt(process.env.DB_PORT, 10),
username: process.env.DB_USER,
});
const testConnection = client`SELECT * FROM users`;
console.log(testQuery); // outputs correctly loaded data
const db = drizzle({
client,
schema,
});
const usersQuery = db.query.users.findMany();
console.log(usersQuery.toSQL().sql); // select "id", "email", "username", "password", "logins", "last_login" from "users" "users"
const users = await tsrDb.query.users.findMany();
console.log(users);

Note that the generated SQL has "users" "users"
- I'm not familiar with postgres but it seems like the second one is an alias for the table. Also note that the file with the error is drizzle-orm/pg-core/session.js
.
Switching to drizzle-orm/mysql2
everything works fine...
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working