stefano
01/10/2024, 10:28 AM<aggregateFn>If(column, filter)
, e.g. sumIf(revenue, period = 'current')
. I don't know how to model the filter part in a custom column expression, I'd have structured it as a WhereDeclaration
but it doesn't seem to be used as an argument to construct an Operand
for the custom column expression. Any ideas how I can do this?stefano
01/10/2024, 10:53 AMWITH <table name> (<column list>)
), but ClickHouse doesn't support the column list. Is there a way to modify this behavior, either through the dialect definition or otherwise, so that the resulting query omits the list of column names?dave08
01/11/2024, 10:23 AM@KomapperProjection
a @KomapperEntity
? It's a bit confusing, since it's not really in the database... and sometimes might not have any relationship to something in the database... (is there a Meta entry generated for it? What would be it's use?). Also it seems like it needs a @KomapperId
even though a projection might not always have one... And it doesn't seem to take into consideration nullable fields with default values... (you have to provide it, and it can't be null
...)
Also, can a projection be used to map the result from many joined tables?dave08
01/11/2024, 3:01 PMstefano
01/17/2024, 7:47 PMIt is recommended that SCHEMA queries are used only for development purposes. For example, it is suitable for the following use cases:
• Create a sample application
• Get a base DDL statements in the early phases of the development project
DDL statements for production environments should be managed separately.What would you recommend for managing the schema and schema migrations? I was going to default to Flyway but I'm curious if there's anything else you'd use
Toshihiro Nakamura
01/20/2024, 2:15 AMdave08
03/03/2024, 1:52 PMdave08
03/03/2024, 1:58 PM@KomapperEmbedded
properties?dave08
03/03/2024, 4:38 PMselect 1 from...
as a column (with a Boolean value), I tried defining:
private fun literalOne(): ScalarExpression<Boolean, Int> {
val name = "literalOne"
return columnExpression(Boolean::class, Int::class, { it > 0 }, name, listOf()) {
append("1")
} as ScalarExpression<Boolean, Int>
}
but it seems like a ScalarExpression
can't be defined... so I can't use a subquery with select(literalOne())
like this as a column value... is there any way to work around this?dave08
03/04/2024, 1:23 PMToshihiro Nakamura
03/08/2024, 3:46 PMToshihiro Nakamura
03/30/2024, 10:33 PMdave08
04/09/2024, 11:01 AM@KomapperColumn
) there instead of on the data class they inherit?dave08
04/09/2024, 12:51 PMInstant
for date in postgres, or do I have to use LocalDate?dave08
04/10/2024, 6:37 AM@KomapperProjection
is a great feature ❤️🚀, there's so many great use cases it fills! I'm just having a little issue... I don't know if it makes sense to support List<...>
as one of the properties when dealing with one-to-many relations... but it would be great if it could be possible! For now it seems like ksp just complains that the property must not be generic... which means that any generics is not allowed?dave08
04/10/2024, 8:58 AMdave08
04/10/2024, 10:09 AMas ColumnExpression<Int, *>
...)?dave08
04/10/2024, 12:30 PMClock.todayIn(TimeZone.UTC)
, I don't know what to use... shouldn't there be a localDateLiteral for this (in jetbrains exposed they actually have such a function...)?dave08
04/10/2024, 1:49 PMQueryDsl.insert(...).single(Foo(id=100, ...))
, will the id be 100? It seems like it just ignores the number I pass (I thought it only ignores 0...)?dave08
04/10/2024, 1:50 PMdave08
04/11/2024, 5:32 AMdave08
04/11/2024, 10:07 AMflatZip
composition queries? Maybe there should be a flatZipNotNull
?dave08
04/11/2024, 12:50 PMQueryDsl.insert(..).values { ... }
when leaving out properties with a default value in the entity data class doesn't insert them automatically in the values block? I could use the single(...)
form, but then I'd have to include my createdAt and updatedAt properties that I'd like Komapper to fill in for me...dave08
04/11/2024, 1:39 PMor()
in a where { }
using `WhereDeclaration`s, but can I write
where {
foo eq ...
or { bar eq .. }
}
to get (foo = ...) or (bar = ...)
?dave08
04/11/2024, 3:21 PMinline fun <reified T : Any> literal(value: T): ColumnExpression<T, T> {
val operand = Operand.SimpleArgument(T::class, value)
return columnExpression(T::class, "literalObject", listOf(operand)) {
visit(operand)
}
}
to use in selectAsXXX functions... I need to put in literals when I use that with
QueryDsl.insert(...).select {
... // here often I need these literals like value classes, or enums... I use a query with selectAsXXX
}
dave08
04/11/2024, 3:24 PMdave08
04/15/2024, 2:21 PMclass KomapperBaseRepository<ENTITY : Any, ID : Any, META : EntityMetamodel<ENTITY, ID, META>>(
private val db: R2dbcDatabase,
private val entityMetamodel: META,
) : RepositoryBase<ENTITY, ID> {
override suspend fun create(entity: ENTITY): ENTITY = db.runQuery(QueryDsl.insert(entityMetamodel).single(entity))
override suspend fun get(id: ID): ENTITY? {
return db.runQuery(QueryDsl.from(entityMetamodel).where { entityMetamodel...? eq id }.singleOrNull())
}
}
// on my domain layer:
interface RepositoryBase<T : Any, ID : Any> {
suspend fun create(entity: T): T
suspend fun get(id: ID): T?
}
but I can't find what to put in my where as the id property...dave08
04/15/2024, 2:22 PMdave08
04/15/2024, 2:42 PMdave08
04/16/2024, 11:11 AM@JvmInline value class SomeId(val value: String) {
val isFoo: Boolean get() = value.startsWith("d-")
}
which is used as an Id in a Komapper entity, and it seems like Komapper thinks that SomeId is a Boolean, not a String...!