jpcafe
jpcafe
DTDrizzle Team
Created by jpcafe on 3/11/2024 in #help
How can i implement ilike in sqlite?
sql`lower(${Recipe.title}) like '%${filters.search.toLowerCase()}%'`
sql`lower(${Recipe.title}) like '%${filters.search.toLowerCase()}%'`
throws an error in turso "LibsqlError: ARGS_INVALID: Arguments do not match SQL parameters: too many parameters, expected 1 found 2". Alternatively is there a way i can reference selected fields? for example if i select
titleLower: sql<string>`lower(${Recipe.title})`.as('titleLower')
titleLower: sql<string>`lower(${Recipe.title})`.as('titleLower')
is there a way i can reference this in a where clause? I know with Kysely you can easily do that but haven't found an answer with drizzle
3 replies
DTDrizzle Team
Created by jpcafe on 2/15/2024 in #help
Using default with `text` json mode creates empty `DEFAULT`
Hi all, entries: text('entries', { mode: 'json' }).$type<number[]>().default([]), results in
CREATE TABLE `User` (
`id` integer PRIMARY KEY NOT NULL,
`entries` text DEFAULT ,
`createdAt` integer DEFAULT CURRENT_TIMESTAMP,
`updatedAt` integer NOT NULL,
`lastSyncedAt` integer
);
CREATE TABLE `User` (
`id` integer PRIMARY KEY NOT NULL,
`entries` text DEFAULT ,
`createdAt` integer DEFAULT CURRENT_TIMESTAMP,
`updatedAt` integer NOT NULL,
`lastSyncedAt` integer
);
which then throws an error when i try to push to Turso. I suspect it's the empty entries default, when i remove all works fine. Is this expected or show i create a issue on github?
3 replies
DTDrizzle Team
Created by jpcafe on 5/20/2023 in #help
TS error: Argument of type PgTableWithColumns is not assignable to parameter of type AnyPgTable
Hi all, after updating to latest i'm getting this TS error. This is my db creation and schema.
import { User } from './schemas/user';

const queryClient = postgres(DATABASE_URL);

const db = drizzle(queryClient, { schema: { User } });
export type DB = typeof db;

db.select().from(User);
import { User } from './schemas/user';

const queryClient = postgres(DATABASE_URL);

const db = drizzle(queryClient, { schema: { User } });
export type DB = typeof db;

db.select().from(User);
4 replies