Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: EXPOSED-494 Inline DSL statement and query functions #2272

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bog-walk
Copy link
Member

Description

Summary of the change:
Add inline modifier to query functions that are passed lambda parameters.

Detailed description:

  • What:
    • Add inline modifier to query functions, where possible, with crossinline modifier on body/block parameters to prevent non-local returns.
    • Instead of using noinline on nullable where lambda parameters, some functions have been duplicated as overloads instead.

Type of Change

Please mark the relevant options with an "X":

  • New feature

Updates/remove existing public API methods:

  • Is breaking change

Affected databases:

  • MariaDB

Checklist

  • The build is green (including the Detekt check)
  • All public methods affected by my PR has up to date API docs

Related Issues

EXPOSED-494

Make as many eligible statement and query functions inline where possible.
Functions with nullable functional type paramaters have been marked noinline, but
this may change upon review.
- Add crossinline keyword to body parameters to prevent non-local returns
- Duplicate functions with null where parameters to allow inline
@bog-walk bog-walk requested a review from e5l October 11, 2024 02:34
@bog-walk bog-walk linked an issue Oct 11, 2024 that may be closed by this pull request
Comment on lines +188 to 193
fun <T : Table> T.deleteReturning(
returning: List<Expression<*>> = columns
): ReturningStatement {
val delete = DeleteStatement(this, where?.let { SqlExpressionBuilder.it() }, false, null)
val delete = DeleteStatement(this, null, false, null)
return ReturningStatement(this, returning, delete)
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created some new overloads to avoid issues with nullable parameters + inline.
I would have liked to be able to call one from the other instead of duplicating logic, but I couldn't get that to work given the nature of SqlExpressionBuilder.() -> Op<Boolean>.

@e5l Please let me know if any of these don't make sense to split just for inline.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look ok

Copy link
Member

@e5l e5l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment on lines +188 to 193
fun <T : Table> T.deleteReturning(
returning: List<Expression<*>> = columns
): ReturningStatement {
val delete = DeleteStatement(this, where?.let { SqlExpressionBuilder.it() }, false, null)
val delete = DeleteStatement(this, null, false, null)
return ReturningStatement(this, returning, delete)
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look ok

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DSL functions should be inlined
2 participants