Skip to content

Commit

Permalink
fix: zod date function is lowercase
Browse files Browse the repository at this point in the history
  • Loading branch information
rintaun committed Dec 10, 2022
1 parent 27696e8 commit f60bbbc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ export const TestTableStandard$Metadata = {
nativeName: "casetest_lower",
nativeType: "text"
},
created_at: {
nativeName: "created_at",
nativeType: "timestamp"
},
domain_test: {
nativeName: "domain_test",
nativeType: "text"
Expand All @@ -76,6 +80,7 @@ export const TestTableStandard$SelectSchema = z.object({
arr_test: z.array(z.string()).nullable(),
caseTest_upper: z.string().nullable(),
casetest_lower: z.string().nullable(),
created_at: z.date(),
domain_test: z.string().nullable(),
enum_arr_test: z.lazy(() => z.array(z.nativeEnum(TestTypeEnum)).nullable()),
enum_test: z.lazy(() => z.nativeEnum(TestTypeEnum)),
Expand All @@ -86,6 +91,7 @@ export const TestTableStandard$InsertSchema = z.object({
arr_test: z.array(z.string()).nullable(),
caseTest_upper: z.string().nullable(),
casetest_lower: z.string().nullable(),
created_at: z.date().optional().or(z.literal(DEFAULT)),
domain_test: z.string().nullable(),
enum_arr_test: z.lazy(() => z.array(z.nativeEnum(TestTypeEnum)).nullable()),
enum_test: z.lazy(() => z.nativeEnum(TestTypeEnum)),
Expand All @@ -96,6 +102,7 @@ export interface TestTableStandard<TJsonbTest = SerializableValueType> {
arr_test: string[] | null;
caseTest_upper: string | null;
casetest_lower: string | null;
created_at: Date;
domain_test: string | null;
enum_arr_test: TestTypeEnum[] | null;
enum_test: TestTypeEnum;
Expand All @@ -106,6 +113,7 @@ export interface TestTableStandard$Insert<TJsonbTest = SerializableValueType> {
arr_test?: string[] | null;
caseTest_upper?: string | null;
casetest_lower?: string | null;
created_at?: Date;
domain_test?: string | null;
enum_arr_test?: TestTypeEnum[] | null;
enum_test: TestTypeEnum;
Expand All @@ -116,6 +124,7 @@ export const TestTableStandard$Types = {
arr_test: "text",
caseTest_upper: "text",
casetest_lower: "text",
created_at: "timestamp",
domain_test: "text",
enum_arr_test: "test_type_enum",
enum_test: "test_type_enum",
Expand Down
3 changes: 2 additions & 1 deletion src/generator/__tests__/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ beforeAll(async () => {
enum_arr_test TEST_TYPE_ENUM[],
jsonb_test JSONB,
"casetest_lower" TEXT,
"caseTest_upper" TEXT
"caseTest_upper" TEXT,
"created_at" TIMESTAMP NOT NULL DEFAULT NOW()
)
`)
await pool.query(sql.unsafe`
Expand Down
2 changes: 1 addition & 1 deletion src/generator/builders/SelectSchemaBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default class SelectSchemaBuilder extends TypeBuilder<VariableStatement>
factory.createIdentifier(nativeType)
)
} else {
value = this.buildZodFunctionCall(nativeType)
value = this.buildZodFunctionCall(nativeType.toLowerCase())
}

if (columnInfo.isArray) {
Expand Down

0 comments on commit f60bbbc

Please sign in to comment.