jeffc
DTDrizzle Team
•Created by jeffc on 11/15/2024 in #help
Bug - snake_case and views
views don't obey snake_case
...
firstName: t.varchar({ length: 256 }),
lastName: t.varchar({ length: 256 }),
...
export const userView = t.pgView('user_view').as((qb) => qb.select().from(users).where(eq(users.role, 'user')));
CREATE VIEW "public"."user_view" AS (select "id", "uuid", "name", "firstName", "lastName", "email", "age", "invitee", "role", "internalRole", "internalRole2", "updated_at", "created_at", "deleted_at" from "users" where "users"."role" = 'user');
783 | query.execute()
784 | }
785 |
786 | function ErrorResponse(x) {
787 | query && (query.cursorFn || query.describeFirst) && write(Sync)
788 | const error = Errors.postgres(parseError(x))
^
PostgresError: column "firstName" does not exist
1 replies
DTDrizzle Team
•Created by jeffc on 11/15/2024 in #help
Possible bug?
type UserID = number;
type Data = {
foo: string,
bar: number,
face: boolean,
};
export const usersWithBrand = pgTable('users_with_brand', {
id: t.integer().primaryKey().generatedByDefaultAsIdentity().$type<UserID>(),
data: t.jsonb().$type<Data>(),
updateCounter: t.integer().default(sql
1
).$onUpdateFn((): SQL => sql${usersWithBrand.updateCounter} + 1
),
updatedAt: t.timestamp({ mode: 'date', precision: 3 }).$onUpdate(() => new Date()),
alwaysNull: t.text().$type<string | null>().$onUpdate(() => null),
});
Every drizzle-kit push will be sending out
ALTER TABLE "users_with_brand" ALTER COLUMN "update_counter" SET DEFAULT 1;2 replies