Skip to content

Conversation

@matchai
Copy link

@matchai matchai commented Nov 7, 2025

Note

The changes are ±30 lines. The bulk of the PR is adding unit tests.

Changes

  • Expose casing as a readonly property in Drizzle instances
  • Pass the newly exposed property as an argument when generating the schema snapshot
  • Unit test casing support for DBs that support pushSchema

Fixes #3913
Fixes #5015

@matchai matchai marked this pull request as ready for review November 7, 2025 01:41
@mintydev789
Copy link

mintydev789 commented Nov 10, 2025

Would this make the following test setup work? Or would it still be necessary to specify the casing a second time?

// Source: https://github.com/drizzle-team/drizzle-orm/discussions/4216
vi.mock("~/server/db/provider.ts", async () => {
  // Use require to defeat dynamic require error
  // (https://github.com/drizzle-team/drizzle-orm/issues/2853#issuecomment-2668459509)
  const { createRequire } = await vi.importActual<typeof import("node:module")>("node:module");
  const require = createRequire(import.meta.url);
  const { pushSchema } = require("drizzle-kit/api") as typeof import("drizzle-kit/api");

  const client = new PGlite();
  // This uses some of the same options from drizzle.config.ts
  const db = drizzle({ client, schema, relations, casing: "snake_case" });

  // Apply schema to db
  const { apply } = await pushSchema(schema, db as any);
  await apply();
 
  return { db };
});

I'm dealing with the same issue of the casing not being respected.

@matchai
Copy link
Author

matchai commented Nov 10, 2025

This would indeed work as you've written your test setup, with the PR merged 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: pushSchema does not respect the casing property. [BUG]: pushSchema doesn't respect the drizzle instance's casing configuration

2 participants