OverHash
ilike with reference
Hey there, I'm looking to perform the following SQL operation:
but unfortunately I'm having trouble doing this in Kysely. Here is my current attempt:
which will compile fine, but unfortunately pg throws a
error: could not determine data type of parameter $1
error when running. I printed the sql query compiled by Kysely and got:
which Pg can't seem to handle.
Does anyone have any suggestions? I recognize that this problem might not necessarily be with Kysely.6 replies
Casting part of a return type
Hi there,
Some of my queries return lots of fields. I want to be able to cast the return value of some of these fields. For example, I have a
SELECT
statement on a numeric field, but pg will parse this to a string. I want to be able to tell this in my output.
- I can't use $.castTo
because this destroys the other values in my SELECT
clause.
- I can't use $.narrowType
because I am casting from number
to string
, not narrowing
Does anyone have any suggestions?
Example:
Here, we lose information about pet_name
. I want to keep information about pet_name
, while also being able to say that first_name
will be returned as a number.38 replies
Selecting result of subtraction with summation
Hey, I'm having trouble translating the effective following Postgresql code to Kysely code:
I tried to use this:
but this yields to a type error:
Does anyone have any ideas about how to safely get around this? Was hoping to avoid using
sql
.
Here's a minimal repro of what I'm trying to do: https://kyse.link/EdviN4 replies
bulk-insert with constant variable as one column
Hey, I'm basically trying to mirror https://stackoverflow.com/questions/6937442/in-postgres-is-it-possible-to-insert-a-constant-combined-with-the-result-of-sel. I can't figure out how I'd achieve this with Kysely.
I'm currently here:
but this doesn't quite work on the
select
statement, since Kysely/TS doesn't like the second argument.
Does anyone know how I could do a INSERT INTO ... SELECT ...
query, where one of the values I am SELECT
ing is a constant (in my case, insertedId
)?4 replies
JSON Object Traversal
Hi everyone, new user of Kysely.
I have the following json object inside a
sess
column:
I'm trying to write a type-safe Kysely query to traverse this. Essentially, I want a Postgresql query that looks like this:
I'm almost there, however, I'm running into some issue getting thjat last ->>
part. Here is what I have so far:
this, unfortunately, generates a query like this:
(notice that the last user -> user_id
is not a ->>
, as it should be) which causes postgresql to fail.
How am I supposed to tell Kysely to use ->>
on the last step there?8 replies
express-session store
Hi, I'm a new user of Kysely.
I'm wondering if there is a way to connect kysely with
express-session
. For example, to use in combination with passport
.
For example, I was wondering if Kysely somehow exposes a pg
compatible pg.Pool
, which would allow me to use something like connect-pg-simple
to have an adapter from the Kysely world to the pg
world.
I couldn't find anything around online or in this Discord, so I'm wondering if the Kysely ecosystem is mature enough to have this stuff around yet? Or any ideas as to how I could go about this without too much pain? 🙂5 replies