drizzle-team / drizzle-team/drizzle-orm
[BUG]: Wrong operator for index with multiple keys in 0.31.0
- Dominant language
- TypeScript
- Stars
- 35.8k
- Forks
- 1.6k
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 4
Description
### Report hasn't been filed before.
- [X] 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.38.0
### What version of `drizzle-kit` are you using?
0.30.0
### Other packages
_No response_
### Describe the Bug
When using `drizzle-kit introspect` to pull a schema with indices there are some cases where UUID get the wrong operator:
```typescript
export const keyFigures = mySchema.table(
'keyfigures',
{
id: integer().notNull(),
compUuid: uuid('comp_uuid').notNull(),
year: varchar({ length: 255 }).notNull(),
// ...
},
(table) => [
index('keyfigures__comp_uuid_idx').using(
'btree',
table.compUuid.asc().nullsLast().op('uuid_ops'),
),
index('keyfigures__comp_uuid_year_idx').using(
'btree',
table.compUuid.asc().nullsLast().op('text_ops'),
table.year.asc().nullsLast().op('text_ops'),
),
],
)
```
In the intropected database the indices are as follows:
**keyfigures__comp_uuid_idx:**

**keyfigures__comp_uuid_year_idx:**

This throws the following error when I push the schema to my test database:
```
error: operator class "text_ops" does not accept data type uuid
```
**Expectectations:**
I expect the indices in the introspected schema to have the same operator classes as the database they are pulled from
**Details:**
As far as I can tell the issue only arises when there are multiple keys on an index. As you can see above `keyfigures__comp_uuid_idx` resolves to the correct operator class (uuid_ops) while `keyfigures__comp_uuid_year_idx` resolves to text_ops for both keys.
Contributor guide
Assessment
This issue has not been assessed yet.