OverHash
OverHash
KKysely
Created by OverHash on 10/15/2024 in #help
ilike with reference
Using
sql`'%'`,
sql`'%'`,
Seemed to do the trick, instead of eb.val("%"). Any other ways to make this more ergonomic?
6 replies
KKysely
Created by OverHash on 10/15/2024 in #help
ilike with reference
I guess I need a way to embed % directly into my query?
6 replies
KKysely
Created by OverHash on 10/15/2024 in #help
ilike with reference
Oh actually I think this is Postgres itself throwing the error? Not pg.
6 replies
KKysely
Created by OverHash on 10/5/2024 in #help
Casting part of a return type
ok, thanks for your help and tips. think its good to close this now!
38 replies
KKysely
Created by OverHash on 10/5/2024 in #help
Casting part of a return type
key being the <number> as the sum, rather than <string>
38 replies
KKysely
Created by OverHash on 10/5/2024 in #help
Casting part of a return type
aha I found my issue, I was using a CTE and
.with("total_quantity", (db) =>
db
.selectFrom("person")
.select((eb) =>
eb.fn
.sum<number>("person.initial_quantity")
.as("quantity_consumed"),
)
)
.with("total_quantity", (db) =>
db
.selectFrom("person")
.select((eb) =>
eb.fn
.sum<number>("person.initial_quantity")
.as("quantity_consumed"),
)
)
38 replies
KKysely
Created by OverHash on 10/5/2024 in #help
Casting part of a return type
but i can't see that being possible
38 replies
KKysely
Created by OverHash on 10/5/2024 in #help
Casting part of a return type
would be good if I could tell pg to only do that for a few columns
38 replies
KKysely
Created by OverHash on 10/5/2024 in #help
Casting part of a return type
I'm not so sure if I want to do that over my entire db
38 replies
KKysely
Created by OverHash on 10/5/2024 in #help
Casting part of a return type
ok sweet, so probably doing things like
eb
.val(parseBodyResult.data.remainingQuantity) // remainingQuantity is a number here
.$castTo<string>()
eb
.val(parseBodyResult.data.remainingQuantity) // remainingQuantity is a number here
.$castTo<string>()
is the way to go?
38 replies
KKysely
Created by OverHash on 10/5/2024 in #help
Casting part of a return type
yep
38 replies
KKysely
Created by OverHash on 10/5/2024 in #help
Casting part of a return type
I can't use .lit there right, because that requires it to be a number? Have to use .val("0") instead?
38 replies
KKysely
Created by OverHash on 10/5/2024 in #help
Casting part of a return type
the actual SQL is fine if you use number type, because internally it is numeric(9, 6)
38 replies
KKysely
Created by OverHash on 10/5/2024 in #help
Casting part of a return type
Property 'isSelectQueryBuilder' is missing in type 'ExpressionWrapper<Database, "person", string>' but required in type 'SelectQueryBuilderExpression<Record<string, number>>'.
Property 'isSelectQueryBuilder' is missing in type 'ExpressionWrapper<Database, "person", string>' but required in type 'SelectQueryBuilderExpression<Record<string, number>>'.
38 replies
KKysely
Created by OverHash on 10/5/2024 in #help
Casting part of a return type
(using BETWEEN clause)
38 replies
KKysely
Created by OverHash on 10/5/2024 in #help
Casting part of a return type
Here's one of my places where it fails using string
38 replies