elitan
elitan
KKysely
Created by elitan on 11/28/2023 in #help
Help with CTE query
Can anyone help me transform this SQL to Kysely? https://kyse.link/?p=s&i=Q7JBZIP6xMpYoEsHJSHi
7 replies
KKysely
Created by elitan on 11/24/2023 in #help
Object literal may only specify known properties, and 'clientId' does not exist in type 'InsertObjec
No description
16 replies
KKysely
Created by elitan on 11/3/2023 in #help
How to order by with embeddings using pgvector?
I'm trying to get this to work:
const raw = db
.selectFrom("embeddingChunks")
.select(["id", "domainPathId"])
.orderBy(sql`embedding::VECTOR <=> '[${embedding.toString()}]'`)
.limit(5);

const c = raw.compile();

console.log({ c });

const res = await raw.execute();
const raw = db
.selectFrom("embeddingChunks")
.select(["id", "domainPathId"])
.orderBy(sql`embedding::VECTOR <=> '[${embedding.toString()}]'`)
.limit(5);

const c = raw.compile();

console.log({ c });

const res = await raw.execute();
But I get this when executing:
error: invalid input syntax for type vector: "[$1]"
....
length: 102,
severity: 'ERROR',
code: '22P02',
detail: undefined,
hint: undefined,
position: '86',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'vector.c',
line: '224',
routine: 'vector_in'
}
error: invalid input syntax for type vector: "[$1]"
....
length: 102,
severity: 'ERROR',
code: '22P02',
detail: undefined,
hint: undefined,
position: '86',
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'vector.c',
line: '224',
routine: 'vector_in'
}
When I run the compiled query manually in TablePlus it works. Any hints?
10 replies
KKysely
Created by elitan on 9/20/2023 in #help
Kysely doesn't work in jest/test environment
For some reason Kysely does not work when I'm running test via Jest. I have a simple Express application and all db.selectFrom(... commands just times out. I tried to log things via:
log(event) {
console.log(event);
log(event) {
console.log(event);
but nothing is logged. When I start the server as usuall, Kysely works as expected. Any idea on how to debug or what could cause this issue?
4 replies
KKysely
Created by elitan on 7/20/2023 in #help
camelCase plugin with a strangely named column
We have a column named cl_companyID (I'm as confused as you) and I have issues with the camelCase plugin because it thinks the name is cl_company_id. Is there a way around this, without renaming the column? I was thinking maybe we could add support with some kind of lookup table with weird names for the plugin to respect.
21 replies
KKysely
Created by elitan on 7/18/2023 in #help
Build a basic Kysely Plugin
Hi, I need some help with a basic plugin I want to build. It's an encrypt/decrypt plugin. This is high level on how I want it to work: - Before data is written to the database, encrypt it - Before data is read back, decrypt it. This should only work for string values. The trick is, not all columns should be encrypted. I'm fine defining tables/columns this will be applied to. Maybe the plugin should have a encrypt function, decrypt function, and a list of table/column pairs this is applicable for? Can anyone help me with some high level help on how to build this?
12 replies