Skip to content
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

Drizzle studio JSON input crashes frontend #378

Open
rkacenski opened this issue Apr 24, 2024 · 2 comments
Open

Drizzle studio JSON input crashes frontend #378

rkacenski opened this issue Apr 24, 2024 · 2 comments
Assignees
Labels

Comments

@rkacenski
Copy link

rkacenski commented Apr 24, 2024

Screen.Recording.2024-04-24.at.2.16.21.PM.mov

See the vid.. when trying to add data to a new row with a column studio errors out with a nondescript error.
Does not happen when editing after the row is created. My work around is to create the row and then edit the column after.

Using

drizzle-kit: v0.20.17
drizzle-orm: v0.29.1
@RomanNabukhotnyi
Copy link

@rkacenski Hey! Can you please share your schema?

@rkacenski
Copy link
Author

Sorry didn't mean to ghost on you..

import { text, pgTable, timestamp, boolean, uuid, json } from 'drizzle-orm/pg-core';
import { createInsertSchema, createSelectSchema } from 'drizzle-zod';
import { z } from 'zod';

export interface CustomJsonPropertyType {
  type: string;
  array_type?: string;
  description?: string;
  default?: string;
  properties?: { [key: string]: CustomJsonPropertyType };
}

const CustomJsonProperty: z.ZodType<CustomJsonPropertyType> = z.object({
  type: z.string(),
  array_type: z.string().optional(),
  description: z.string().optional(),
  default: z.string().optional(),
  properties: z.record(z.lazy(() => CustomJsonProperty)).optional()
})

export type CustomJsonPropertySchemaType = z.infer<typeof CustomJsonProperty>

const CustomTypePropertiesSchema = z.record(CustomJsonProperty)

export type CustomTypesProperties = z.infer<typeof CustomTypePropertiesSchema>

export const custom_types = pgTable('custom_type', {
  id: uuid('id').defaultRandom().primaryKey(),
  name: text('name').notNull(),
  description: text('description'),
  company_id: text('company_id').notNull(),
  created_at: timestamp('created_at').notNull().defaultNow(),
  created_by: text('created_by').notNull(),
  modified_at: timestamp('modified_at').notNull().defaultNow(),
  modified_by: text('modified_by').notNull(),
  version: text('version').notNull(),
  properties: json('properties').$type<CustomTypesProperties>().notNull().default({}),
  is_public: boolean('is_public').notNull().default(false)
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants