drizzle-orm icon indicating copy to clipboard operation
drizzle-orm copied to clipboard

[BUG]: Wrong column name when using PgEnum.array()

Open dancamdev opened this issue 1 year ago • 4 comments

What version of drizzle-orm are you using?

0.30.6

What version of drizzle-kit are you using?

0.20.14

Describe the Bug

Given the following enum definition:

export const playerPosition = pgEnum("player_position", ['defender', 'midfield', 'attacker'])

I'm defininying this table, notice the column name being position:

export const players = pgTable("players", {
	id: serial("id").primaryKey().notNull(),
	position: playerPosition("position").array(),
});

Running drizzle-kit push:pg results in a correctly created table with id and position columns.

If I am to run drizzle-kit introspect:pg the position column gets renamed into playerPosition as if matching the enum name:

export const players = pgTable("players", {
	id: serial("id").primaryKey().notNull(),
	playerPosition: playerPosition("position").array(),
});

This only happens if I'm using a PgEnum.array() as a value, without using .array() it works as expected.

Expected behavior

Running drizzle-kit introspect:pg should keep the correct column name:

export const players = pgTable("players", {
	id: serial("id").primaryKey().notNull(),
	position: playerPosition("position").array(),
});

Environment & setup

No response

dancamdev avatar Apr 02 '24 15:04 dancamdev

@realmikesolo any updates on this? I'm willing to look into it but I only found a mirror repository for drizzle-kit. Where should I be looking for the source code?

dancamdev avatar Apr 09 '24 18:04 dancamdev

@dancamdev hey, I'll fix that in the next release. This one is fast fix, so shouldn't be a problem. Thanks a lot for your ticket!

AndriiSherman avatar Apr 10 '24 08:04 AndriiSherman

@AndriiSherman thank you for the effort! I'll be waiting on the fix - do you have an ETA?

dancamdev avatar Apr 10 '24 08:04 dancamdev

Any update on this guys?

senghuotlay avatar May 19 '24 05:05 senghuotlay

This should be fixed in [email protected] If you still encounter this issue, please reopen the ticket

AndriiSherman avatar Aug 22 '24 13:08 AndriiSherman