https://kotlinlang.org logo
Join Slack
Powered by
# komapper
  • d

    dave08

    10/09/2024, 9:34 AM
    @Toshihiro Nakamura I was wondering if I could re-use a Command for different results by declaring it Exec and mapping it myself after running the dryRun query with Jasync, or is Exec parsed differently in way that wouldn't accept regular select statements?
    t
    • 2
    • 1
  • d

    dave08

    10/09/2024, 9:35 AM
    I could always use Many and then just make a dummy mapper that maps to nothing, but is that really necessary?
  • d

    dave08

    10/10/2024, 11:43 AM
    Little idea, I've seen templating languages that either ignore whitespace or not depending on how the directives are declared (like
    /*-
    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?
    t
    • 2
    • 4
  • d

    dave08

    10/10/2024, 12:00 PM
    Another nice thing would be to have a
    @KomapperProjectionDef
    for when the model is declared in another module that shouldn't have a dependency to Komapper...
    t
    • 2
    • 10
  • d

    dave08

    10/10/2024, 1:27 PM
    @Toshihiro Nakamura I have my JasyncDatabase implementation for running Commands, but I see I need to implement another method for projections... what's the simplest way to do it (I posted the current code in the thread)?
    t
    • 2
    • 8
  • d

    dave08

    10/29/2024, 9:04 AM
    @Toshihiro Nakamura It'd be nice to have a template function
    List.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?
    t
    • 2
    • 3
  • d

    dave08

    10/29/2024, 9:11 AM
    Also, maybe there should be a check for stray
    ?
    in KomapperCommands(/templates?), they don't seem to make sense... and one might forget a few when migrating queries to templates.
    t
    • 2
    • 11
  • d

    dave08

    10/29/2024, 9:13 AM
    Lastly, how would a List<Int> parameter in a KomapperCommand be rendered in
    unnest(/*listParam*/::int[])
    ?
    t
    • 2
    • 25
  • t

    Toshihiro Nakamura

    11/16/2024, 5:12 AM
    Hello everyone! Komapper v4.0.0 has been released! 🎉 https://github.com/komapper/komapper/releases/tag/v4.0.0
    🎉 3
  • t

    Toshihiro Nakamura

    11/28/2024, 11:08 PM
    Currently, Komapper does not work with Kotlin 2.1, but a compatible version is scheduled for release this weekend.
    👍🏼 1
  • t

    Toshihiro Nakamura

    11/29/2024, 11:55 PM
    Hey everyone! We just released Komapper v5.0.0! 🎉 This update brings improvements to the Spring Boot auto-configuration features and adds support for Kotlin v2.1.0. Be sure to check out the release notes and the migration guide for all the details. https://github.com/komapper/komapper/releases/tag/v5.0.0
    🎉 2
  • t

    Toshihiro Nakamura

    01/19/2025, 3:25 AM
    Hello everyone, We’re excited to announce the release of Komapper 5.1.0! This version introduces support for collecting SQL execution statistics, a Spring Boot test slice feature, and more. https://github.com/komapper/komapper/releases/tag/v5.1.0
    🙌 1
  • t

    Toshihiro Nakamura

    02/09/2025, 1:57 AM
    Hello everyone, We have released Komapper 5.2.0. This release includes enhanced support for Quarkus and Spring Boot, as well as fixes for edge-case bugs. https://github.com/komapper/komapper/releases/tag/v5.2.0
  • d

    dave08

    02/12/2025, 4:58 PM
    I have a case coming up more and more... a
    @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:
    Copy code
    @KomapperPartial([
    """....""",
    """...."""
    ]) data class P(...)
    
    @KomapperCommand("""
       /*> p.1 */
    ....
       /*> p.2 */
    ...
    """) data class Q(p: P, ...)...
    this would help encapsulate a whole functionality in one partial.
    t
    • 2
    • 8
  • d

    dave08

    02/16/2025, 12:52 PM
    @Toshihiro Nakamura Can I refer to objects that I have in my KomapperCommand from a KomapperPartial? It's a bit funny to keep on having to pass them down in both...
    t
    • 2
    • 2
  • d

    dave08

    02/16/2025, 1:37 PM
    @Toshihiro Nakamura I think we once spoke about spacing before and after template placeholders... I'm wondering if somehow the adding of whitespace could be controlled in a future version of Komapper. Say
    /*% 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...
    t
    • 2
    • 1
  • d

    dave08

    02/16/2025, 1:39 PM
    _
    could be any character you decide... I just gave an example
  • d

    dave08

    02/17/2025, 1:17 PM
    Are there any plans to add
    /*%elif ... */
    or when blocks to templates any time soon? It's a bit cumbersome to have to use tons of if/ends...
    t
    • 2
    • 2
  • d

    dave08

    02/23/2025, 11:29 AM
    @Toshihiro Nakamura It seems like DryRunResult's sql when an error was thrown on a query with a flatMap returns the first query even though the error seems to be in the query inside the flatMap -- that makes sense since the dryRun can't have any idea of a runtime failure, but it makes it impossible to get a normal log with the sql and params being run when getting such a runtime failure... unless I'm missing something? (Regular runtime failures only give a small part of the sql that had bad grammar... which isn't too helpful in tracking down the problem)
    t
    • 2
    • 6
  • t

    Toshihiro Nakamura

    03/08/2025, 3:50 AM
    Hello everyone, We have released Komapper v5.2.1. In this release, we fixed an issue where retrieving data from PostgreSQL using R2DBC resulted in missing records and altered row order. https://github.com/komapper/komapper/releases/tag/v5.2.1
  • t

    Toshihiro Nakamura

    05/23/2025, 11:05 PM
    Hi everyone! 🎉 Komapper v5.3.0 is now available. In this release we’ve added community-contributed features and fixed several Quarkus-related issues. Please note that support for Spring Framework 5 and Spring Boot 2 has ended. We recommend upgrading to Spring 6 and Spring Boot 3. https://github.com/komapper/komapper/releases/tag/v5.3.0
    👀 1
  • t

    Toshihiro Nakamura

    06/20/2025, 9:58 PM
    Hello, everyone! Komapper v5.4.0 is out! ✨ New:
    insertable
    property for @KomapperColumn • Enhanced Spring Boot Testcontainers integration • Improved build performance • Updated dependencies: Spring Boot 3.5.3, Quarkus 3.23.3, and more Check it out: https://github.com/komapper/komapper/releases/tag/v5.4.0
  • d

    dave08

    07/09/2025, 3:59 PM
    Hi @Toshihiro Nakamura! I have my JasyncDatabase that had a little bug that a command wasn't running properly... I noticed I had :
    Copy code
    override fun templateExecuteQuery(context: TemplateExecuteContext): JasyncRunner<Long> =
            JasyncRunner {
               conn.sendQuery(stmt.sql).rowsAffected
            }
    but that seems wrong, since I'm not using the context's valueMap... I'll post what seems right to me in the thread, but is it? Or should I just be using the context object, w/o dryRun?
    t
    • 2
    • 5
  • d

    David Hamilton

    07/11/2025, 8:54 AM
    Hi. Are there any plans to create LLMS documents for Komapper? I'm currently testing use of AI assistance with Kotlin libraries, and am finding that it struggles with smaller projects, or ones with recent breaking changes. Creation of such a file (or files - see https://llmstxt.org/ ) would greatly ease library adoption.
    t
    • 2
    • 2
  • d

    dave08

    09/04/2025, 3:52 PM
    Hi @Toshihiro Nakamura! Wondering if I can reference an enum in a Command from another gradle module in an
    /*% if someEnum == ... */
    ? I tried fully qualifying it like in the docs, but it doesn't seem to work...
    t
    • 2
    • 2
  • t

    Toshihiro Nakamura

    09/12/2025, 7:16 PM
    Hello, everyone! Komapper v5.5.0 has been released. Highlights: • FULL OUTER JOIN support in Query DSL • Support for
    kotlin.time.Instant
    Release notes: https://github.com/komapper/komapper/releases/tag/v5.5.0
    👍 3
    👍🏼 1
  • m

    Min Thet Naing

    09/17/2025, 3:18 PM
    Do komapper support multiple updates in a single query like UPDATE ... FROM ... with VALUES in PostgreSQL? Example pgsql query UPDATE your_table AS t SET column1 = new_values.col1, column2 = new_values.col2 FROM ( VALUES (key1, value1_col1, value1_col2), (key2, value2_col1, value2_col2), (key3, value3_col1, value3_col2) ) AS new_values (key_column, col1, col2) WHERE t.key_column = new_values.key_column;
    t
    • 2
    • 2
  • m

    Min Thet Naing

    09/18/2025, 9:06 AM
    Should I use inline value class with domain models and entity class with komapper and the mapping between theme is the good practice? I want to know the usage about inline value classes with komapper?
    t
    • 2
    • 2
  • t

    Toshihiro Nakamura

    10/18/2025, 2:43 AM
    Hello, everyone! Komapper v5.6.0 is out! 🎉 You can now specify
    length
    ,
    precision
    , and
    scale
    for data types when generating DDL.
    Copy code
    @KomapperEntity
    data class Product(
        @KomapperId
        val id: Int,
        @KomapperColumn(length = 255)
        val name: String,
        @KomapperColumn(precision = 10, scale = 2)
        val price: BigDecimal,
        @KomapperColumn(length = 1000)
        val description: String?
    )
    Release notes: https://github.com/komapper/komapper/releases/tag/v5.6.0
  • m

    Min Thet Naing

    10/18/2025, 5:24 AM
    Copy code
    interface DBConnectionFactory {
        fun connect(dbConfig: DbConfig, ktorEnvironment: KtorEnvironment): R2dbcDatabase
    }
    
    object PostgresConnectionFactory: DBConnectionFactory {
    
        override fun connect(dbConfig: DbConfig, ktorEnvironment: KtorEnvironment): R2dbcDatabase {
            val connectionFactory = ConnectionFactories.get(
                builder()
                    .option(DRIVER, "pool")
                    .option(PROTOCOL, "postgresql")
                    .option(HOST, dbConfig.host)
                    .option(PORT, dbConfig.port) // default
                    .option(USER, dbConfig.user)
                    .option(PASSWORD, dbConfig.password)
                    .option(DATABASE, dbConfig.dbName)
                    .apply {
                        if (ktorEnvironment == KtorEnvironment.Prod) {
                            option(SSL, true)
                            option(SSL_MODE, SSLMode.REQUIRE)
                        }
                    }
                    .option(PoolingConnectionFactoryProvider.MAX_IDLE_TIME, Duration.ofMillis(5000))
                    .option(PoolingConnectionFactoryProvider.INITIAL_SIZE, 5)
                    .option(PoolingConnectionFactoryProvider.MAX_SIZE, 10) // pool size
                    .build())
    
            val db = R2dbcDatabase(
                connectionFactory = connectionFactory,
                dialect = PostgreSqlR2dbcDialect()
            )
    
            return db
        }
    }
    When the Ktor server shutdown do I need to manually close the r2dbc-pool connection? If I need to manually close the pool connection, how can I do this? Please show me the example and thank you.
    t
    • 2
    • 3