https://kotlinlang.org logo
#exposed
Title
# exposed
y

Yoavya

10/08/2020, 4:45 PM
Hi 🙂 I am having a difficulty with the join mechanism: apparently if you hold a reference to a table and you join them
Copy code
object 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
Copy code
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?
👍 1
t

tapac

10/13/2020, 8:41 AM
Please try to specify that you don't need to use implicit reference by using extended join version:
Copy code
UserQuestionTable.join(OtherTable, JoinType.LEFT, onColumn = null, otherColumn = null, additionalConstraint = { /* your condition */ })
y

Yoavya

10/13/2020, 8:56 AM
tried that, it still adds a condition
user_question.oid = other.id AND (my condition)
as a hack solution I removed the reference in the exposed table (code only). using just a long type for now
should I open an issue in github?
t

tapac

10/13/2020, 9:03 AM
Oh, I found a bug. Will fix it now.
y

Yoavya

10/13/2020, 9:03 AM
YES, awesome, thanks
4 Views