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

[BUG]: Drizzle Studio doesn't save strings in JSON fields #3586

Open
1 task done
helloryuko opened this issue Nov 21, 2024 · 0 comments
Open
1 task done

[BUG]: Drizzle Studio doesn't save strings in JSON fields #3586

helloryuko opened this issue Nov 21, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@helloryuko
Copy link

Report hasn't been filed before.

  • I have verified that the bug I'm about to report hasn't been filed before.

What version of drizzle-orm are you using?

0.36.3

What version of drizzle-kit are you using?

0.28.1

Other packages

No response

Describe the Bug

What is the undesired behavior?

Drizzle Studio row editor doesn't let using strings (a valid JSON object!) in a JSON column.
Video demonstration: https://youtu.be/XeFh62uAOag

What are the steps to reproduce it?

  1. Create a jsonb column in schema
  2. Push the schema
  3. Run Drizzle Studio
  4. Try to enter a string instead of an object (e.g. "foo", not {"foo": "bar"})

What is the desired result?

Same as I expect from INSERT INTO items (id, name) VALUES ('test', '"a json stringy!!"'); - creating a row with JSON column name containing a string.

What database engine are you using?

Postgres with pg driver.

Schema

import { boolean, jsonb, pgTable, varchar } from "drizzle-orm/pg-core";

type Translatable = {
    ua: string | null;
    ru: string | null;
    en: string | null;
} | string;

const translatable = () => jsonb().$type<Translatable>();

export const items = pgTable("items", {
    id: varchar({ length: 128 }).primaryKey(),

    name: translatable(),
    description: translatable(),

    sellable: boolean().default(true),
});
@helloryuko helloryuko added the bug Something isn't working label Nov 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant