Composite types support #2437
Replies: 4 comments
-
Is this being looked into? I can into it if not |
Beta Was this translation helpful? Give feedback.
-
not a priority for the team right now. |
Beta Was this translation helpful? Give feedback.
-
Is there a workaround for this? We're trying to migrate to Drizzle but during introspection we're getting errors for our composite types, can we simply change it to |
Beta Was this translation helpful? Give feedback.
-
What's the current situation with Composite Types for postgresql? There is an active issue #2430 at Drizzle repo from which I took this code, presumably used as a workaround for Composite Types: const co2eEmissionFactorPgType = customType<{
data: {
id: string;
value: number;
};
driverData: string;
}>({
dataType: () => "co2e_emission_factor_type",
toDriver(data): string {
return `ROW('${data.id}', ${data.value})::co2e_emission_factor_type`;
},
fromDriver(data: string) {
const match = /\((?<id>.+),\s?(?<value>.+)\)/.exec(data);
if (!match) {
throw new Error("Invalid co2e_emission_factor_type format");
}
return {
id: match.groups?.id ?? "",
value: Number(match.groups?.value),
};
},
});
const testTable = pgTable("test", {
// ...
test: co2eEmissionFactorPgType("co2_emissions").array().notNull()
}); Can you approve of us using it? I have not tested it myself yet, even worse it looks like a DIY - usage mentioned on the docs (https://orm.drizzle.team/docs/custom-types#common-way-of-defining-custom-types) is barely like his code. Moreover, it outputs the following migration, which will... fail?: CREATE TABLE IF NOT EXISTS "test" (
"id" serial PRIMARY KEY NOT NULL,
"test" "co2e_emission_factor_type"
); |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
https://www.postgresql.org/docs/current/rowtypes.html
Beta Was this translation helpful? Give feedback.
All reactions