drizzle-team / drizzle-team/drizzle-orm

[BUG]: Introspection from MySQL Database creates invalid Schema involving double single quotes.

Open
#1,754 12 comments 1 reaction 1 assignee Claimed by @AndriiSherman View on GitHub
bug bug/fixed-in-beta drizzle/kit priority
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.29.3

### What version of `drizzle-kit` are you using?

0.20.10-3c347a7

### Describe the Bug

When running `npm drizzle-kit introspect:mysql`, I get a schema that includes double "single quotes" as in the following:

```ts
export const content = mysqlTable("content", {
id: int("id").notNull(),
virtualPath: varchar("virtual_path", { length: 255 }).notNull(),
pid: varchar("pid", { length: 750 }).notNull(),
pageTitle: varchar("page_title", { length: 75 }).default(''Untitled Document'').notNull(),
navTitle: varchar("nav_title", { length: 25 }).default('NULL'),
protected: mysqlEnum("protected", ['Y','N']).default(''N'').notNull(),
metaData: varchar("meta_data", { length: 750 }).default('NULL'),
content: longtext("content").notNull(),
navPlacement: longtext("navPlacement").default('NULL'),
weight: decimal("weight", { precision: 10, scale: 2 }).notNull(),
dateRecorded: datetime("date_recorded", { mode: 'string'}).notNull(),
lastModified: timestamp("last_modified", { mode: 'string' }).default('current_timestamp()'),
});
```

### Expected behavior

I expect to see:

```ts
export const content = mysqlTable("content", {
id: int("id").notNull(),
virtualPath: varchar("virtual_path", { length: 255 }).notNull(),
pid: varchar("pid", { length: 750 }).notNull(),
pageTitle: varchar("page_title", { length: 75 }).default('Untitled Document').notNull(),
navTitle: varchar("nav_title", { length: 25 }).default('NULL'),
protected: mysqlEnum("protected", ['Y','N']).default('N').notNull(),
metaData: varchar("meta_data", { length: 750 }).default('NULL'),
content: longtext("content").notNull(),
navPlacement: longtext("navPlacement").default('NULL'),
weight: decimal("weight", { precision: 10, scale: 2 }).notNull(),
dateRecorded: datetime("date_recorded", { mode: 'string'}).notNull(),
lastModified: timestamp("last_modified", { mode: 'string' }).default('current_timestamp()'),
});
```

### Environment & setup

Using fresh SvelteKit 2.0 with TypeScript enabled.

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.