Ivan
10/05/2020, 6:15 AMTobias Marschall
10/07/2020, 2:05 PMexists
in Kotlin Exposed? https://stackoverflow.com/questions/64245773/equivalent-of-sql-exists-in-kotlin-exposedYoavya
10/08/2020, 4:45 PMobject UserQuestionTable : LongIdTable("user_question") {
val uid = reference("uid", UserTable, onDelete = ReferenceOption.CASCADE)
val oid = optReference("oid", OtherTable)
val allow = bool("allow").default(true)
}
but you have a complex join that is not just the reference ids equal
UserQuestionTable.join(OtherTable, JoinType.LEFT, additionalConstraint = {
(OtherTable.id inList otherIds) and (
(OtherTable.id eq UserQuestionTable.oid) or (
UserQuestionTable.oid.isNull() and (UserQuestionTable.allow eq true)
)
)
})
but the output query is added a user_question.oid = other.id
and then the rest of the additional constraint query
what can I do to remove this addition?Volodya Gurdin
10/09/2020, 7:54 AMentity.parent?.id?.value
code will throw No transaction in context
although entity table has parent_id column and it should know parent id value when you fetched it, so no additional queries needed to DB. And exposed seems to know that, cause if i put this code under transaction block - parent id will be returned without any additional queriesJP
10/09/2020, 8:18 PMvar a = -1
newSuspendedTransaction {
try {
a = Users.insert {
it[username] = model.username
} get Users.userId
} catch (e: Exception){
}
}
return a
Any ideas as to how I can return the value from the transaction while also handling error? I've tried handling the error outside the transaction, but for some reason, transactions don't let errors bubble uptapac
10/14/2020, 11:06 PMYoavya
10/20/2020, 8:52 AMoverride fun replace(
table: Table,
data: List<Pair<Column<*>, Any?>>,
transaction: Transaction
): String {
val builder = QueryBuilder(true)
val sql = if (data.isEmpty()) {
""
} else {
data.appendTo(builder, prefix = "VALUES (", postfix = ")") { (col, value) -> registerArgument(col, value) }.toString()
}
val columns = data.map { it.first }
val def = super.insert(false, table, columns, sql, transaction)
val uniqueCols = table.primaryKey?.columns
if (uniqueCols.isNullOrEmpty()) {
transaction.throwUnsupportedException("PostgreSQL replace table must supply at least one primary key.")
}
val conflictKey = uniqueCols.joinToString { transaction.identity(it) }
return def + "ON CONFLICT ($conflictKey) DO UPDATE SET " + columns.joinToString { "${transaction.identity(it)}=EXCLUDED.${transaction.identity(it)}" }
}
is this intentional? why not include all unique indices ? I can try fixing it with a PR if needed 🙂dave08
10/20/2020, 2:09 PMdave08
10/21/2020, 9:49 AMWyatt Kennedy
10/27/2020, 3:15 AMuserTransaction(userId: Long, db: Database? = null, statement: Transaction.() -> T)
, but I can't find anywhere to store data on the Transaction object, or any way to subclass transaction and use that. Any suggestions?Patrick Doering
10/27/2020, 10:20 AMYoavya
11/02/2020, 4:43 PMDas135
11/04/2020, 11:35 AMSELECT 'custom1' as custom, id, name, address FROM persons
Ivan
11/06/2020, 8:43 AMJP
11/09/2020, 12:49 AMtransaction
would do in Exposed). If there is another tool other than Flyway that might be better suited for this, then I'd be happy to hear about that as well.Joel
11/10/2020, 5:06 PMval fullName: String get() = listOfNotNull(firstName, lastName).joinToString(" ")
private var cachedFullName by UserDetailsTable.fullName
companion object : EntityClass<String, UserDetailsView>(UserDetailsTable) {
init {
EntityHook.subscribe { action ->
action.toEntity(this)?.let { it.cachedFullName = it.fullName }
}
}
}
Is there a cleaner way to set a computed value using the DAO?Kenneth Wußmann
11/11/2020, 3:01 PMSELECT
with all relations to memory?JP
11/13/2020, 4:13 AMtransaction
? I want to take one in as a parameter in a function, and then execute the transaction. However, I've only ever seen it in the inline style of transaction {...}
and having it execute thereBen Tzou
11/16/2020, 6:22 PMJP
11/17/2020, 12:06 AMtransaction{
Table.addColumn(...)
}
?spand
11/17/2020, 2:41 PMinsertIgnore
actually failed or not ?Joe Atkins-Turkish
11/18/2020, 11:18 PMvarchar("name").comment("The customer's first name")
), but there wasn’t much support for it. Can anyone here think of any good/idiomatic approaches, or is there an official one that I’ve missed?maxmello
11/20/2020, 10:09 AMOrderItems.deleteWhere { OrderItems.id inSubQuery ( OrderItems.innerJoin(Orders).innerJoin(Items).slice(Orders.id).select { Orders.status eq 0 and (Items.alias eq "String") } ) }
(untested) would probably work as a workaround. It seems that deleteWhere is only available from a Table
, not a Join
or their superclass ColumnSet
. The delete implementation does not seem to support DELETE <TableName> FROM …:
package org.jetbrains.exposed.sql.vendors // Default.kt
open fun delete(
ignore: Boolean,
table: Table,
where: String?,
limit: Int?,
transaction: Transaction
): String {
// ...
return buildString {
append("DELETE FROM ")
append(transaction.identity(table))
if (where != null) {
append(" WHERE ")
append(where)
}
// ...
}
}
Mathias Rørvik
11/23/2020, 2:21 PMfun getSymbolId(symbol: String): Int {
transaction {
Symbols.select { Symbols.symbol eq symbol }.toList().first()
}
}
Tristan Blakers
12/02/2020, 11:12 PMMichael
12/08/2020, 3:21 PMLbenyehu
12/21/2020, 9:19 AMDownloadPizza
01/04/2021, 11:01 AMPatrick Doering
01/18/2021, 5:20 AMAdam
01/20/2021, 1:55 PMtransaction { }
block? https://github.com/JetBrains/Exposed/wiki/DSL