Closed incompletude closed 2 months ago
Not sure what is going on here, sometimes it works, sometimes it doesnt. I think is something related to vscode and ts.
Typescript's type system is structural so it alongside many developers are not concerned with preserving the order of the keys in an object. This would be a very hard thing to implement in Drizzle for very little reward, by that I mean that preserving the order of keys is a very niche use case to begin with. You could create a utility type if you really need it, something like:
type User = { name: string; id: number; };
type Reorder<T, K extends (keyof T)[]> = {
[Key in K[number]]: T[Key];
};
type Ordered = Reorder<User, ['id', 'name']>; // { id: number; name: string; }
Not ideal, sure, but this is more of a limitation of Typescript's type system rather than Drizzle.
What version of
drizzle-orm
are you using?LTS
What version of
drizzle-kit
are you using?LTS
Describe the Bug
This is more like an enhancement, and I'm not sure is even possible, but it would be nice if the
InferSelectModel
preserved the column order as defined in the table:Resulting type is:
Should be:
When working with complex types having the ordering as is helps organize stuff around.
Expected behavior
No response
Environment & setup
No response