Greg Poirier
02/27/2024, 9:52 PMeq
operator when comparing two columns one of Column<String> with Column<EntityID<String>>. I've got a way around this, but I'm wondering if there is a cleaner way. More detail in 🧵Chantal Loncle
02/28/2024, 12:33 PMSašo
03/01/2024, 4:24 PMnewSuspendedTransaction
and withSuspendTransaction
, with comments explaining that the blocks will be run separately in "some thread from the dispatcher" (unclear if this is the same thread or multiple threads from same dispatcher) but both reusing the same transaction. However, just a couple of lines lower, there is a warning about not sharing a transaction between multiple threads. I am not sure if the example is doing just that (sharing a transaction between multiple threads), but regardless of that, I'm curious what the example would look like if there was a suspending function added to the mix, that also needs to reuse the same transaction.
In order to not do https://xyproblem.info/ , I am trying to implement a standard queue using a postgres table, basically a SELECT * FROM queue WHERE somecolumn IS NULL FOR UPDATE SKIP LOCKED
-> do some work that might or might not include suspending functions and will also need to do additional database queries, so I definitely want to reuse the existing transaction/connection -> set somecolumn
to the finish time.
Appreciate any help or pointers to examples!Fernando Sanchez (Perraco Labs)
03/01/2024, 7:29 PMBastien Leveque
03/03/2024, 7:42 PM2024-03-03 18:04:50 java.lang.reflect.InvocationTargetException
2024-03-03 18:04:50 at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
2024-03-03 18:04:50 at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77)
2024-03-03 18:04:50 at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
2024-03-03 18:04:50 at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
2024-03-03 18:04:50 at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
2024-03-03 18:04:50 at kotlin.reflect.jvm.internal.calls.CallerImpl$Constructor.call(CallerImpl.kt:41)
2024-03-03 18:04:50 at kotlin.reflect.jvm.internal.KCallableImpl.call(KCallableImpl.kt:107)
2024-03-03 18:04:50 at org.jetbrains.exposed.dao.EntityClass$entityCtor$1.invoke(EntityClass.kt:32)
2024-03-03 18:04:50 at org.jetbrains.exposed.dao.EntityClass$entityCtor$1.invoke(EntityClass.kt:32)
2024-03-03 18:04:50 at org.jetbrains.exposed.dao.EntityClass.createInstance(EntityClass.kt:229)
2024-03-03 18:04:50 at org.jetbrains.exposed.dao.EntityClass.new(EntityClass.kt:264)
2024-03-03 18:04:50 at org.jetbrains.exposed.dao.EntityClass.new(EntityClass.kt:247)
2024-03-03 18:04:50 at fr.ftnl.economy.database.models.BankAccount2$Companion.create$lambda$1(BankAccountTable2.kt:29)
2024-03-03 18:04:50 at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.inTopLevelTransaction$run(ThreadLocalTransactionManager.kt:215)
2024-03-03 18:04:50 at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.access$inTopLevelTransaction$run(ThreadLocalTransactionManager.kt:1)
2024-03-03 18:04:50 at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt$inTopLevelTransaction$1.invoke(ThreadLocalTransactionManager.kt:241)
2024-03-03 18:04:50 at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.keepAndRestoreTransactionRefAfterRun(ThreadLocalTransactionManager.kt:249)
2024-03-03 18:04:50 at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.inTopLevelTransaction(ThreadLocalTransactionManager.kt:240)
2024-03-03 18:04:50 at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt$transaction$1.invoke(ThreadLocalTransactionManager.kt:190)
2024-03-03 18:04:50 at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.keepAndRestoreTransactionRefAfterRun(ThreadLocalTransactionManager.kt:249)
2024-03-03 18:04:50 at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:160)
2024-03-03 18:04:50 at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction(ThreadLocalTransactionManager.kt:146)
2024-03-03 18:04:50 at org.jetbrains.exposed.sql.transactions.ThreadLocalTransactionManagerKt.transaction$default(ThreadLocalTransactionManager.kt:145)
2024-03-03 18:04:50 at fr.ftnl.economy.database.models.BankAccount2$Companion.create(BankAccountTable2.kt:28)
2024-03-03 18:04:50 at fr.ftnl.economy.bot.commands.modules.Balance.action(Balance.kt:26)
2024-03-03 18:04:50 at fr.ftnl.economy.bot.commands.InteractionCommandHandler.dispatch(InteractionCommandHandler.kt:72)
2024-03-03 18:04:50 at fr.ftnl.economy.bot.commands.InteractionCommandHandler$dispatch$1.invokeSuspend(InteractionCommandHandler.kt)
2024-03-03 18:04:50 at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
2024-03-03 18:04:50 at kotlinx.coroutines.UndispatchedCoroutine.afterResume(CoroutineContext.kt:270)
2024-03-03 18:04:50 at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:102)
2024-03-03 18:04:50 at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
2024-03-03 18:04:50 at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
2024-03-03 18:04:50 at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:584)
2024-03-03 18:04:50 at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:793)
2024-03-03 18:04:50 at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:697)
2024-03-03 18:04:50 at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:684)
2024-03-03 18:04:50 Caused by: java.lang.IllegalStateException: Column and factory point to different tables
2024-03-03 18:04:50 at org.jetbrains.exposed.dao.Referrers.<init>(References.kt:62)
2024-03-03 18:04:50 at org.jetbrains.exposed.dao.EntityClass.referrersOn(EntityClass.kt:324)
2024-03-03 18:04:50 at fr.ftnl.economy.database.models.BankAccount2.<init>(BankAccountTable2.kt:51)
2024-03-03 18:04:50 ... 36 more
thank you in advance for your helpdavid dereba
03/06/2024, 5:59 AMjava.sql.SQLSyntaxErrorException: User 'cashio' has exceeded the 'max_questions' resource (current value: 1000)
reactormonk
03/08/2024, 3:35 PMDeepak Gahlot
03/09/2024, 7:17 AMFernando Sanchez (Perraco Labs)
03/09/2024, 12:03 PM@CreationTimestamp
and @UpdateTimestamp
annotations, to automatically handle the creation and update timestamps for entity fields?Jeffrey Kwok
03/14/2024, 7:11 PMStartWarsFilmActors
and in the dao class like:
class StarWarsFilm(id: EntityID<Int>) : IntEntity(id) {
companion object : IntEntityClass<StarWarsFilm>(StarWarsFilms)
...
var actors by Actor via StarWarsFilmActors
var extraDataFromJunctionTable // ?
...
}
Tyler Kinkade
03/16/2024, 9:34 AMAkshdeep Singh
03/21/2024, 1:31 PMFernando Sanchez (Perraco Labs)
03/22/2024, 2:55 PMRodrigo Silva
03/26/2024, 9:07 PMSahit Sadono
03/28/2024, 5:25 AMJocelyne Abi Haidar
03/29/2024, 8:55 AMFernando Sanchez (Perraco Labs)
03/29/2024, 9:31 AMopen class TimestampedTable(name: String) : Table(name = name) {
val createdAt = datetime(name = "created_at").defaultExpression(CurrentDateTime)
val updatedAt = datetime(name = "updated_at").defaultExpression(CurrentDateTime)
}
object SomeTable : TimestampedTable(name = "some_table_name") {
// Additional fields.
}
This approach works well for me, with no issues so far. My question is if there are any additional considerations or potential pitfalls I should be aware of when using inheritance in this manner with the Exposed framework.Jaap Beetstra
04/02/2024, 8:33 AMPaulo Cereda
04/02/2024, 5:58 PMStephcraft
04/03/2024, 8:40 PMexec("SHOW TABLE STATUS FROM $databaseName") { result -> /* ... */ }
exec("SHOW CREATE TABLE $table") { result -> /* ... */ }
I get the following error:
[16:33:56 WARN]: Transaction attempt #0 failed: java.sql.SQLException: Can not issue executeUpdate() or executeLargeUpdate() with statements that produce result sets. Statement(s): SHOW TABLE STATUS FROM s6244_Exposed
org.jetbrains.exposed.exceptions.ExposedSQLException: java.sql.SQLException: Can not issue executeUpdate() or executeLargeUpdate() with statements that produce result sets
Is this a bug? Am I doing something wrong? Is there a way around it? Thank you 🙏Dio
04/04/2024, 8:20 AMThomas Ploch
04/08/2024, 11:41 AMfun valueFromDB(value: kotlin.Any): kotlin.Any
in the IColumnType
interface. Since columns can be nullable, why is the signature here not allowing null values? This forces implementers to additionally check null somewhere else, and not within a custom column type implementation.Jack Endorsing
04/09/2024, 9:59 AMKarl Azzam
04/09/2024, 4:30 PMKarl Azzam
04/10/2024, 6:13 PMSELECT
u.id AS user_id,
ARRAY_AGG(ua.entity_path) AS paths
FROM
foo_schema.user_table u
JOIN
foo_schema.user_attributes_table ua ON u.id = ua.user_id
GROUP BY
u.id
I instead am doing this where i get multiple rows per user for each user's entity path.
SELECT
u.id AS user_id,
ua.entity_path AS path
FROM
foo_schema.user_table u
JOIN
foo_schema.user_attributes_table ua ON u.id = ua.user_id
GROUP BY
u.id, ua.entity_path
Md Sadique Inam
04/15/2024, 4:46 AMwith()
? For example, we have a field signifying a soft-deleted row: `deleted`; is there a way to specify that we don't want to eager-fetch rows whose deleted = 't'
? or by giving expression with reference in Entity class.
example
object Users : UUIDTable("x") {
val deleted: Column<Boolean> = bool("deleted").default(false)
val teamId: Column<UUID> = reference("team_id", Teams)
}
class User(id: EntityID<UUID>) : UUIDEntity(id) {
companion object : UUIDEntityClass<User>(Users)
var deleted by Users.deleted
}
object Teams : UUIDTable("y") {
val deleted: Column<Boolean> = bool("deleted").default(false)
}
class Team(id: EntityID<UUID>) : UUIDEntity(id) {
companion object : UUIDEntityClass<Team>(Teams)
var deleted by table.deleted
val members by User referrersOn Users.teamId
}
Chantal Loncle
04/19/2024, 4:14 AMMERGE INTO target_table AS t
USING source_table AS s
ON s.id = t.id
WHEN NOT MATCHED THEN
INSERT (id, name, amount)
VALUES (s.id, s.name, s.amount)
WHEN MATCHED AND s.amount < 42 THEN
UPDATE SET amount = t.amount + s.amount
WHEN MATCHED THEN
DELETE;
Please react with the option below that reads better to you, or leave a comment 🧵 with an alternative name 🤔
Here's DSL option 1️⃣:
TargetTable.mergeFrom(SourceTable) {
insertWhenNotMatched {
// insert values
}
updateWhenMatched(and = SourceTable.amount less 42) {
// update values
}
deleteWhenMatched()
}
And here's DSL option 2️⃣:
TargetTable.mergeFrom(SourceTable) {
whenNotMatchedInsert {
// insert values
}
whenMatchedUpdate(and = SourceTable.amount less 42) {
// update values
}
whenMatchedDelete()
}
Thanks in advance for your input thank you colorMaria Krishtal
04/19/2024, 10:24 AMRichie Bresnan
04/19/2024, 5:44 PMcreate unique index on mytable(col, nullableCol) nulls not distinct;
Vinicius Araujo
04/19/2024, 9:26 PMselect * from mytable where 'Journal'=ANY(pub_types);
where pub_types
is a string array data type.