VSCode Intellisense Error: "Type 'PgTableWithColumns... is not assignable to type 'SQL<unknown>..."

Hey, im new to Drizzle and am encountering this intelliselse error on VSCode. Notably the code runs fine. I am using Planetscale and Cloudflare Pages Functions. Thank you in advance! Schema
export const projects = pgTable('Projects', {
project: text("project").notNull().primaryKey(),
backgroundImageUuid: text('background_image_uuid'),
siteId: text("site_id").notNull().primaryKey(),
systemId: text("system_id").notNull().primaryKey(),
});
export const projects = pgTable('Projects', {
project: text("project").notNull().primaryKey(),
backgroundImageUuid: text('background_image_uuid'),
siteId: text("site_id").notNull().primaryKey(),
systemId: text("system_id").notNull().primaryKey(),
});
Query
const result3 = await db(env)
.select({
projects.project,
projects.backgroundImageUuid
})
.from(projects)
.where(
and(
eq(projects.siteId, data.siteId),
eq(projects.systemId, siteConfig.systemId)
)
);
const result3 = await db(env)
.select({
projects.project,
projects.backgroundImageUuid
})
.from(projects)
.where(
and(
eq(projects.siteId, data.siteId),
eq(projects.systemId, siteConfig.systemId)
)
);
Error
Type 'PgTableWithColumns<{ name: "Projects"; schema: undefined; columns: { project: PgColumn<{ name: "project"; tableName: "Projects"; dataType: "string"; columnType: "PgText"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: [...]; baseColumn: never; }, {}, {}>; backgroundImageUuid: PgColu...' is not assignable to type 'SQL<unknown> | Aliased<unknown> | MySqlColumn<ColumnBaseConfig<ColumnDataType, string>, object> | MySqlTable<TableConfig> | SelectedFieldsFlat<...>'.
Type 'PgTableWithColumns<{ name: "Projects"; schema: undefined; columns: { project: PgColumn<{ name: "project"; tableName: "Projects"; dataType: "string"; columnType: "PgText"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: [...]; baseColumn: never; }, {}, {}>; backgroundImageUuid: PgColu...' is not assignable to type 'SelectedFieldsFlat...
Type 'PgTableWithColumns<{ name: "Projects"; schema: undefined; columns: { project: PgColumn<{ name: "project"; tableName: "Projects"; dataType: "string"; columnType: "PgText"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: [...]; baseColumn: never; }, {}, {}>; backgroundImageUuid: PgColu...' is not assignable to type 'SQL<unknown> | Aliased<unknown> | MySqlColumn<ColumnBaseConfig<ColumnDataType, string>, object> | MySqlTable<TableConfig> | SelectedFieldsFlat<...>'.
Type 'PgTableWithColumns<{ name: "Projects"; schema: undefined; columns: { project: PgColumn<{ name: "project"; tableName: "Projects"; dataType: "string"; columnType: "PgText"; data: string; driverParam: string; notNull: true; hasDefault: false; enumValues: [...]; baseColumn: never; }, {}, {}>; backgroundImageUuid: PgColu...' is not assignable to type 'SelectedFieldsFlat...
No description
3 Replies
piscopancer
piscopancer9mo ago
@IEatBeans this is a typescript issue when your project runs and constantly recompiles. try starting a typescript build task in watch mode in a separate terminal, so follow this route: toolbar -> terminal -> run task -> typescript -> watch. then your errors may be gone, moreover your whole project will be scanned for type errors as this task is live no matter what files you got opened atm
Mykhailo
Mykhailo9mo ago
Hello, @IEatBeans! You just need to provide keys in object:
const result3 = await db(env)
.select({
project: projects.project,
backgroundImageUuid: projects.backgroundImageUuid
})
.from(projects)
.where(
and(
eq(projects.siteId, data.siteId),
eq(projects.systemId, siteConfig.systemId)
)
);
const result3 = await db(env)
.select({
project: projects.project,
backgroundImageUuid: projects.backgroundImageUuid
})
.from(projects)
.where(
and(
eq(projects.siteId, data.siteId),
eq(projects.systemId, siteConfig.systemId)
)
);
wait, you should use mysqlTable instead of pgTable, because planetscale is MySQL database
IEatBeans
IEatBeansOP9mo ago
Ah ok, that makes sense. I thought it was weird that it was wanting to use pg, idk where in the docs I found that. Must have copied it from the wrong section
Want results from more Discord servers?
Add your server