drizzle-team / drizzle-team/drizzle-orm

[FEATURE]: Support SET Type in MySQL with mysqlSet

Open
#1,989 2 comments 1 reaction 0 assignees View on GitHub
db/mysql drizzle/kit enhancement
Dominant language
TypeScript
Stars
35.8k
Forks
1.6k
Avg merge
2d 7h
Merged PRs (30d)
4

Description

### Describe what you want

Add support for the SET type in the same manor as `mysqlEnum`, should be created the same way, example schema:
```ts
export const blogPostsTable = mysqlTable("posts", {
title: varchar("title", { length: 255 }).notNull().primaryKey(),
content: text("content").notNull(),
slug: varchar("slug", { length: 255 }).notNull(),
tags: mysqlSet("tags", ["javascript", "typescript", "react", "vue", "nextjs", "nuxt", "angular"]).notNull()
});
```

MySQL Docs: https://dev.mysql.com/doc/refman/8.0/en/set.html

Query
```ts
const posts: Post[] = await db
.select()
.from(blogPostsTable)
.where(findInSet(blogPostsTable.tags, ["react", "nextjs"]));
```
```sql
SELECT * FROM posts WHERE FIND_IN_SET('react,nextjs',tags);
```

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.