- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG]: drizzle-kit pull
doesn't work with md5
index
#3745
Comments
This appears to happen when reading the schema from a database with a compound index where one of the index components is a non-column expression. I'm having a similar issue. That is, in your example:
It happens when running This is extra confusing because I've tracked the issue down to https://github.dev/drizzle-team/drizzle-orm/blob/04c91434c7ac10aeb2923efd1d19a7ebf10ea9d4/drizzle-kit/src/serializer/pgSerializer.ts#L1534 The Downstream, this null causes the Working with Claude gave me this alternative SQL that seems to work when tested on my project SELECT DISTINCT ON (t.relname, ic.relname, k.i)
t.relname as table_name,
ic.relname AS indexname,
k.i AS index_order,
i.indisunique as is_unique,
am.amname as method,
ic.reloptions as with,
CASE
WHEN i.indkey[k.i-1] != 0 THEN a.attname
ELSE pg_get_indexdef(i.indexrelid, k.i, true)
END AS column_name,
CASE WHEN pg_get_expr(i.indexprs, i.indrelid) IS NOT NULL THEN 1 ELSE 0 END AS is_expression,
i.indoption[k.i-1] & 1 = 1 AS descending,
i.indoption[k.i-1] & 2 = 2 AS nulls_first,
pg_get_expr(i.indpred, i.indrelid) as where,
opc.opcname
FROM pg_class t
LEFT JOIN pg_index i ON t.oid = i.indrelid
LEFT JOIN pg_class ic ON ic.oid = i.indexrelid
CROSS JOIN LATERAL generate_series(1, array_length(i.indkey, 1)) AS k(i)
LEFT JOIN pg_attribute AS a ON i.indrelid = a.attrelid AND i.indkey[k.i-1] = a.attnum
JOIN pg_namespace c on c.oid = t.relnamespace
LEFT JOIN pg_am AS am ON ic.relam = am.oid
JOIN pg_opclass opc ON opc.oid = ANY(i.indclass) Pretty diff from the current SQL query: https://www.diffchecker.com/D6VK4atj/ I'm personally not great at Postgres SQL, so do very much take this with a grain of salt. I can't meaningfully read the original query, nor the one Claude wrote. Hopefully someone with better SQL can read, give feedback, and create a PR |
…on (non-column) members fix drizzle-team#3745
…on (non-column) members fix drizzle-team#3745
Fixed by #3888 , waiting for a maintainer to review + merge! |
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
I'm getting the following error using
drizzle-kit pull
. I'm kind of lost, please help!This is the table in question.
Okay after removing these two index it works. Am I missing something?
https://discord.com/channels/1043890932593987624/1070810929475883038/1316310831364964442
The text was updated successfully, but these errors were encountered: