Use real dates instead of iso string everywhere

This commit is contained in:
Zoe Roux
2026-01-03 19:46:28 +01:00
parent 4a02371402
commit 243701a5c5
46 changed files with 176 additions and 225 deletions
+8 -11
View File
@@ -1,5 +1,5 @@
import {
type Column,
Column,
type ColumnsSelection,
getTableColumns,
is,
@@ -12,6 +12,8 @@ import {
View,
ViewBaseConfig,
InferSelectModel,
isTable,
isSQLWrapper,
} from "drizzle-orm";
import type { CasingCache } from "drizzle-orm/casing";
import type { AnyMySqlSelect } from "drizzle-orm/mysql-core";
@@ -162,10 +164,11 @@ export const unnestValues = <
.select(
Object.fromEntries([
...keys.map((x) => [x, sql.raw(`"${dbNames[x]}"`)]),
...computed.map((x) => [
x,
(columns[x].defaultFn?.() ?? columns[x].onUpdateFn!()).as(dbNames[x]),
]),
...computed.map((x) => {
let def = columns[x].defaultFn?.() ?? columns[x].onUpdateFn!();
if (!isSQLWrapper(def)) def = sql`${def}`;
return [x, def.as(dbNames[x])];
}),
]) as {
[k in keyof typeof typeInfo.$inferInsert]-?: SQL.Aliased<
(typeof typeInfo.$inferInsert)[k]
@@ -255,9 +258,3 @@ export const isUniqueConstraint = (e: unknown): boolean => {
cause.code === "23505"
);
};
export const normalizeDate = (date: Column) => {
return sql<string>`to_char(${date}, 'YYYY-MM-DD"T"HH24:MI:SS"Z"')`.as(
date.name,
);
};