Invalid drizzle query

I'm trying to run a search for tests using drizzle studio, but I'm getting this error: invalid drizzle query.
db.query.users.findMany();
db.query.users.findMany();
Schema
import {
sqliteTable,
AnySQLiteColumn,
uniqueIndex,
text,
integer,
} from "drizzle-orm/sqlite-core";
import { sql } from "drizzle-orm";

export const users = sqliteTable(
"users",
{
id: text("id").primaryKey().notNull(),
name: text("name").notNull(),
registration: text("registration").notNull(),
createdAt: integer("created_at"),
level: integer("level").notNull(),
password: text("password").notNull(),
intModifiers: integer("int_modifiers").default(false).notNull(),
},
(table) => {
return {
registrationUnique: uniqueIndex("users_registration_unique").on(
table.registration,
),
};
},
);
import {
sqliteTable,
AnySQLiteColumn,
uniqueIndex,
text,
integer,
} from "drizzle-orm/sqlite-core";
import { sql } from "drizzle-orm";

export const users = sqliteTable(
"users",
{
id: text("id").primaryKey().notNull(),
name: text("name").notNull(),
registration: text("registration").notNull(),
createdAt: integer("created_at"),
level: integer("level").notNull(),
password: text("password").notNull(),
intModifiers: integer("int_modifiers").default(false).notNull(),
},
(table) => {
return {
registrationUnique: uniqueIndex("users_registration_unique").on(
table.registration,
),
};
},
);
9 Replies
Mykhailo
Mykhailo8mo ago
Hello @Leonardo Barbosa - Creatus! Is it your schema from drizzle studio runner or from aplliaction?
Leonardo Barbosa - Creatus
This is a schema from drizzle studio runner the schema in my application is
import { createId } from "@paralleldrive/cuid2";
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";

export const users = sqliteTable("users", {
id: text("id")
.$defaultFn(() => createId())
.primaryKey(),
name: text("name").notNull(),
registration: text("registration").notNull().unique(),
createdAt: integer("created_at", { mode: "timestamp" }),
level: integer("level").notNull(),
password: text("password").notNull(),
isDeleted: integer("is_deleted", { mode: "boolean" })
.notNull()
.default(false),
});
import { createId } from "@paralleldrive/cuid2";
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";

export const users = sqliteTable("users", {
id: text("id")
.$defaultFn(() => createId())
.primaryKey(),
name: text("name").notNull(),
registration: text("registration").notNull().unique(),
createdAt: integer("created_at", { mode: "timestamp" }),
level: integer("level").notNull(),
password: text("password").notNull(),
isDeleted: integer("is_deleted", { mode: "boolean" })
.notNull()
.default(false),
});
Mykhailo
Mykhailo8mo ago
This is bug with drizzle studio and default values
Leonardo Barbosa - Creatus
Default values has deleted,
export const users = sqliteTable("users", {
id: text("id")
.$defaultFn(() => createId())
.primaryKey(),
name: text("name").notNull(),
registration: text("registration").notNull().unique(),
createdAt: integer("created_at", { mode: "timestamp" }),
level: integer("level").notNull(),
password: text("password").notNull(),
});
export const users = sqliteTable("users", {
id: text("id")
.$defaultFn(() => createId())
.primaryKey(),
name: text("name").notNull(),
registration: text("registration").notNull().unique(),
createdAt: integer("created_at", { mode: "timestamp" }),
level: integer("level").notNull(),
password: text("password").notNull(),
});
And the bunx drizzle-kit generate:sqlite and bunx drizzle-kit push:sqlite commands were performed schema drizzle studio:
import {
sqliteTable,
AnySQLiteColumn,
uniqueIndex,
text,
integer,
} from "drizzle-orm/sqlite-core";
import { sql } from "drizzle-orm";

export const users = sqliteTable(
"users",
{
id: text("id").primaryKey().notNull(),
name: text("name").notNull(),
registration: text("registration").notNull(),
createdAt: integer("created_at"),
level: integer("level").notNull(),
password: text("password").notNull(),
},
(table) => {
return {
registrationUnique: uniqueIndex("users_registration_unique").on(
table.registration,
),
};
},
);
import {
sqliteTable,
AnySQLiteColumn,
uniqueIndex,
text,
integer,
} from "drizzle-orm/sqlite-core";
import { sql } from "drizzle-orm";

export const users = sqliteTable(
"users",
{
id: text("id").primaryKey().notNull(),
name: text("name").notNull(),
registration: text("registration").notNull(),
createdAt: integer("created_at"),
level: integer("level").notNull(),
password: text("password").notNull(),
},
(table) => {
return {
registrationUnique: uniqueIndex("users_registration_unique").on(
table.registration,
),
};
},
);
Karol
Karol8mo ago
Any update on this @Mykhailo ? My postgres db is getting invalid defaults all over the place too and studio does not allow me to test my queries:
status: varchar("status", { length: 255 }).default('inactive'::character varying),
type: varchar("type", { length: 255 }).default(NULL::character varying).notNull(),
status: varchar("status", { length: 255 }).default('inactive'::character varying),
type: varchar("type", { length: 255 }).default(NULL::character varying).notNull(),
Mykhailo
Mykhailo7mo ago
Hello @Karol! Unfortunately, it is not fixed yet
vkongv
vkongv6mo ago
is this fixed? I am getting this too, hopefully the screencast would help?
vkongv
vkongv6mo ago
I'm using Supabase postgres
Max Forbang
Max Forbang6mo ago
I'm getting the same exact thing.
No description
Want results from more Discord servers?
Add your server