dave08
08/14/2024, 10:25 AMsql
property doesn't give me a regular sql statement with `?`s and I'd suppose that the args
don't give me what to bind for all the ?
, but rather some format Komapper uses... is there some kind of api that does give me an sql with all the ?
and all the params to bind with (even if they're repeated in the statement...). I need to make a temporary compat layer with Jasync, and I would like to use it's prepared statements until I have the time to fully migrate.Toshihiro Nakamura
08/14/2024, 10:43 AMsql
property of DryRunResult
does include ?
. If the sql
property does not contain all the ?
placeholders that would actually be issued, it might be because the dry run is not using the correct database configuration. You can easily retrieve all the values to be bound as well.
Please try the following code.
val query = QueryDsl.insert(a).single(Address(street = "street A"))
val result = query.dryRun(db.config) // or `db.dryRunQuery(query)`
// sql with all the ?
val sql = result.sql
// all the params to bind with the sql
val allArgs = result.args.map { it.any }
dave08
08/15/2024, 12:59 PMToshihiro Nakamura
08/17/2024, 2:12 AMdave08
09/11/2024, 10:01 AMselect...
((FLOOR(RANDOM() * (100 - 0 + 1)) + 5)::BIGINT) AS random,
(OTHER.tags_token::INT[] & ?::INT[]) AS similarity
from ...
dave08
09/11/2024, 4:04 PMAS foo
to the field in select that it should use that in the order by?Toshihiro Nakamura
09/16/2024, 12:13 AMKomapperPartial
annotation is now applied to classes, and these classes are passed as parameters to commands, streamlining how SQL templates reference partials.
For more details on this and other changes, check out the release notes:
👉 https://github.com/komapper/komapper/releases/tag/v3.0.0
We’re excited to see how you’ll use this new feature! 🙌dave08
09/17/2024, 11:30 AMdave08
09/17/2024, 11:34 AMORDER BY name, address,
) instead of having to use the more verbose _`_has_next` test)_Toshihiro Nakamura
10/06/2024, 12:03 AMfor
directive to simplify code.
2. Improved error messages to better indicate where issues occur in SQL.
https://github.com/komapper/komapper/releases/tag/v3.1.0dave08
10/09/2024, 9:34 AMdave08
10/09/2024, 9:35 AMdave08
10/10/2024, 11:43 AM/*-
for removing whitespace before the directive), this could be useful when declaring more complex @KomapperCommands
, keeping normal formatting for the sql while still staying within the editor's bounderies (not having to scroll horizontally too much...), what do you think @Toshihiro Nakamura?dave08
10/10/2024, 12:00 PM@KomapperProjectionDef
for when the model is declared in another module that shouldn't have a dependency to Komapper...dave08
10/10/2024, 1:27 PMdave08
10/29/2024, 9:04 AMList.size()
... or maybe I can just use the property on the list straight from the List<Int>
parameter in the KomapperCommand? If so, why are there all those functions on CharSequence and String? It seems like I'm not getting any compile errors when using /* listParam.size */
so does that mean it works?dave08
10/29/2024, 9:11 AM?
in KomapperCommands(/templates?), they don't seem to make sense... and one might forget a few when migrating queries to templates.dave08
10/29/2024, 9:13 AMunnest(/*listParam*/::int[])
?Toshihiro Nakamura
11/16/2024, 5:12 AMToshihiro Nakamura
11/28/2024, 11:08 PMToshihiro Nakamura
11/29/2024, 11:55 PMToshihiro Nakamura
01/19/2025, 3:25 AMToshihiro Nakamura
02/09/2025, 1:57 AMdave08
02/12/2025, 4:58 PM@KomapperPartial
that has two parts... the WITH ... before the sql I need to put it in and the actual place I need it in (like adding a JOIN to that WITH, or an ORDER BY by it...). One possibility is having the annotation be able to receive an array of sql parts (using the same parameters in the class they're annotating), and then being able to use it:
@KomapperPartial([
"""....""",
"""...."""
]) data class P(...)
@KomapperCommand("""
/*> p.1 */
....
/*> p.2 */
...
""") data class Q(p: P, ...)...
this would help encapsulate a whole functionality in one partial.dave08
02/16/2025, 12:52 PMdave08
02/16/2025, 1:37 PM/*% if ... */\n
would add a new line, but /*% if ... *_/\n
would suppress any whitespace after it and before the next text it contains (whereas /_*% if ... */\n
would do the opposite) allowing to make the sql templates look nicer, while at the same time making printing out the generated sqls and testing against them simpler and nicer...dave08
02/16/2025, 1:39 PM_
could be any character you decide... I just gave an exampledave08
02/17/2025, 1:17 PM/*%elif ... */
or when blocks to templates any time soon? It's a bit cumbersome to have to use tons of if/ends...dave08
02/23/2025, 11:29 AMToshihiro Nakamura
03/08/2025, 3:50 AM