Kristian Notari
Explore posts from serversDHDistant Horizons
•Created by Kristian Notari on 6/8/2024 in #help-me
Moving fast remove lods behind, regenerate after a while
16 replies
Static/reusable custom window functions
Hello, I'm trying to buld a properly typed
array_agg
window function and would like to reuse the existing FunctionModule
in a reusable way, so to have orderby, over, and so on.
Is there a way to get the function module you get from fn.agg
outside of an expression builder and without creating a puppet kysely instance, so to create an array_agg
function and return what fn.agg
return but properly typed?
As an example:
(right now there's no sql.fn
forcing you to use a kysely instance or an expression builder to access the fn
function module)3 replies
On Conflict do update set ALL to be inserted columns
Here I am once again with a question for the on conflict bit in postgres. Would there be a way to automatically compose an update set statement for the on conflict do update bit with the information about all the columns we're going to insert, and automatically do an update with the
excluded
for those?
Example here5 replies
cmpr as eb call SqlBool return type
Hello, missed a couple of updates and now I'm back updating to latest. Found out
eb.cmpr
has been removed and I now need to use eb()
as a function. Is there an easy way to get back a boolean
instead of a SqlBool
?
Before I just needed to call it like eb.cmpr<boolean>
. Thanks!
(I mean, other than a plain type assertion)4 replies
Error "isSelectQueryBuilder" while using doUpdateSet on conflict
Hello, I get an error when dealing with an update object factory for
doUpdateSet
expression during an on conflict statement for an insert.
From my experiments, if the select type of the column is different (not assignable to) the insert/update types than something breaks at the type level and gives me an error
Repro:
https://kyse.link/?p=s&i=Wt7lre2AUUH7EdAInOja16 replies
Subquery type error when using generics
I have the following simple query being generated by my function
f
:
and it works fine. If I add a generic for reusing the same function with different tables (all sharing the common col1
column) it works fine, until I get to the sub query whereRef
(even if I constraint the generic to a single value, which is the same table
as before):
12 replies
createQueryId
Is this function supposed to be exported and used in users code? I'm handling query execution with a custom executor and the
executeQuery
method asks me for a QueryId
. Am I supposed to use kysely internal implementation or am I free to use a custom one? It's just a random string I see, but does it involve something else internally?
I'm asking cause the default import is set to: import { createQueryId } from "kysely/dist/cjs/util/query-id"
20 replies
Insert expression type safe
Is there a way to make
.expression
calls while inserting to a table to return an "InsertObject" or an array of column name / value as when using .values
method so to have type safety in the query?
Example right now:
Example wanted:
24 replies
Property "values" missing when Inspecting InsertQuery ValuesNode
I'm having some troubles upgrading from 0.22.0 to 0.23.4, because I have a custom plugin which gets some columns as input for each database table and prevent any other column to be used as the target of an InsertQuery (this way I can silently pass
{ id: 42, username: "John", nonExistingColumn: "error at runtime" }
as an insert value for my user
table without worrying about excessive properties in the values.
I have overriden the:
and before the upgrade I was checking if my insert query values are actual values I need to filter to remove values for non existing columns but right now I have this error saying there's no values
property inside the values node:
This is due to the node.values being a OperationNode
which only has:
There used to be a ValuesNode
instead, after checking for its kind "ValuesNode". But now it's just an OperationNode and I can't access values directly.
Do you know how to solve?7 replies