is this the proper way to set transaction local va...
# komapper
s
is this the proper way to set transaction local variables for row level security policies or is there something built in in komapper? (using r2dbc)
Copy code
db.withTransaction(TransactionAttribute.REQUIRES_NEW) { tx ->
    db.runQuery {
        QueryDsl.executeScript("SELECT set_config('app.tenant_id', '$tenantId', true);")
    }
    db.runQuer {...}
}
t
Your approach is fine.
executeScript
can execute any SQL.
👍🏻 1
s
Although, would using composite functions give me a theoretical performance improvement?
Copy code
db.withTransaction(TransactionAttribute.REQUIRES_NEW) { tx ->
    db.runQuery {
        QueryDsl.executeScript("SELECT set_config('app.tenant_id', '$tenantId', true);").andThen(QueryDsl...)
    }
}
t
No, you won’t get any performance improvement. It simply increases reusability.
s
I see. I wasn't sure if this runs the queries as one or if it doesn't matter and is the same as running in the same transaction anyway. Thank you!
👍 1