Skip to content

[BUG]: 1.0.0-beta.2 - drizzle-kit push does consider json (jsonb) key order relevant #5119

@michaelschufi

Description

@michaelschufi

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?

1.0.0-beta.2-0f52822

What version of drizzle-kit are you using?

1.0.0-beta.2-0f52822

Other packages

No response

Describe the Bug

Drizzle Kit is not ignoring the order of json object keys when diffing the default of a Postgres (v17) jsonb column for the command drizzle-kit push.

Repro

  1. Define a default value for a jsonb column
    data: jsonb('data')
      .$type<SomeType>()
      .notNull()
      .default({
        b: 2,
        a: 1,
      })
    Notice the key b is defined before a.
  2. Run drizzle-kit push
  3. Confirm the initial column def. E.g. ALTER TABLE public.myTable ADD "data" jsonb DEFAULT '{"a": 1, "b": 2}'::jsonb NOT NULL;
  4. Run drizzle-kit push again

Expected vs. Actual

I expect the push command to complete since no changes are necessary. However, we see that drizzle-kit wants to update the default value of the column again:

┌─── public.myTable.data column changed: 
│ default: '{"bar": {"a": 1, "b": 2}}' -> '{"b":2,"a":1}' 
├─── 
│ ALTER TABLE "myTable" ALTER COLUMN "data " SET DEFAULT '{"b":2,"a":1}'; 
└───

Note
drizzle-kit won't update the column again if the order of the keys b and a are swapped (a first, then b).

Also, a quick shoutout to all of the maintainers for the beta release. Many longstanding bugs in drizzle-kit don't happen anymore and I'm really happy to use it more now.

Metadata

Metadata

Assignees

No one assigned

    Labels

    1.0.0-beta.*bugSomething isn't workingbug/fixed-in-betaThis bug has been fixed in beta (or will be soon).

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions