irelynx
DTDrizzle Team
•Created by irelynx on 1/15/2024 in #help
Weird Query builder behavior (extras)
I am not sure how exactly it works under the hood, but all "queries" that you
await
- will be executed and you will receive an execution result, but if you will not await
- it can be used as a subquery later in your code.
I am not sure though is it possible to store them separately or not (like, create special file with all subqueries and import one of them then it needed)24 replies
DTDrizzle Team
•Created by irelynx on 1/15/2024 in #help
Weird Query builder behavior (extras)
I am not sure, but it can happens because of
Try to remove
await
, and check again24 replies
DTDrizzle Team
•Created by irelynx on 1/15/2024 in #help
Weird Query builder behavior (extras)
yeap, everything is fine now.
24 replies
DTDrizzle Team
•Created by irelynx on 1/15/2024 in #help
Weird Query builder behavior (extras)
😀
24 replies
DTDrizzle Team
•Created by irelynx on 1/15/2024 in #help
Weird Query builder behavior (extras)
I will try it out on bigger query and write down if everything is fine or not.
Thanks again for your help!
24 replies
DTDrizzle Team
•Created by irelynx on 1/15/2024 in #help
Weird Query builder behavior (extras)
oh, finally! i changed your code a little bit and now it produces valid SQL!
produced SQL:
24 replies
DTDrizzle Team
•Created by irelynx on 1/15/2024 in #help
Weird Query builder behavior (extras)
now generated query looks like this:
24 replies
DTDrizzle Team
•Created by irelynx on 1/15/2024 in #help
Weird Query builder behavior (extras)
yeah, sorry for awkward naming
24 replies
DTDrizzle Team
•Created by irelynx on 1/15/2024 in #help
Weird Query builder behavior (extras)
what do you mean by this message?
24 replies
DTDrizzle Team
•Created by irelynx on 1/15/2024 in #help
Weird Query builder behavior (extras)
i tried to remove
.as("avgPrice").avgPrice
and added .getSQL().as('avgPrice')
, then query builds, but it looks like this:
24 replies
DTDrizzle Team
•Created by irelynx on 1/15/2024 in #help
Weird Query builder behavior (extras)
Thanks for your answer, but unfortunately it didn't help much:
1. TypeScipt linter arguing:
2. Also, there is runtime error:
24 replies
DTDrizzle Team
•Created by irelynx on 9/10/2023 in #help
How to add custom SQL queries during or after migration in drizzle schema?
But I guess it is fine to create separate migration file manually for that kind of requirements 🙂
Thanks again!
9 replies
DTDrizzle Team
•Created by irelynx on 9/10/2023 in #help
How to add custom SQL queries during or after migration in drizzle schema?
for example, index with sorting one field in ascending order, and other in descending (aka
create index if not exists "idx" on "tablename" ("field1" ASC, "field2" DESC)
)
or with where clause in it (aka create index if not exists "idx" on "tablename" ("field1" ASC, "field2" DESC) where "field3"='value'
)9 replies
DTDrizzle Team
•Created by irelynx on 9/10/2023 in #help
How to add custom SQL queries during or after migration in drizzle schema?
Hi Raphaël, thanks for your response.
Hmm, i think this solution can do the trick, but is there really no any other way to do it inside schema file?
9 replies