drizzle-team / drizzle-team/drizzle-orm
[BUG]: Getting started with MariaDB: "You have an error in your SQL syntax" - create table with serial auto_increment
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### What version of `drizzle-orm` are you using?
0.36.0
### What version of `drizzle-kit` are you using?
0.27.0
### Describe the Bug
Using the schema from the tutorial
```
export const usersTable = mysqlTable('users_table', {
id: serial().primaryKey(),
name: varchar({ length: 255 }).notNull(),
age: int().notNull(),
email: varchar({ length: 255 }).notNull().unique(),
});
```
will result in the following SQL syntax:
```
CREATE TABLE `users_table` (
`id` serial AUTO_INCREMENT NOT NULL,
`name` varchar(255) NOT NULL,
`age` int NOT NULL,
`email` varchar(255) NOT NULL,
CONSTRAINT `users_table_id` PRIMARY KEY(`id`),
CONSTRAINT `users_table_email_unique` UNIQUE(`email`)
```
resulting in an invalid sql syntax.
Apparently `auto_increment` is already included in the `serial` type, so using `serial auto_increment` is invalid syntax.
### Expected behavior
On the first ever contact with a new framework it always feels good to be able to complete the initial tutorial without any errors. Especially since there is not much information online about why `serial auto_increment` does not work. ChatGPT finally helped.
Expectation would be that Drizzle knows to not use `serial auto_increment` together.
### Environment & setup
MariaDB 10.6.5
Contributor guide
Assessment
This issue has not been assessed yet.