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

Merged
merged 3 commits into from
Oct 28, 2024

Conversation

bog-walk
Copy link
Member

@bog-walk bog-walk commented Oct 11, 2024

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

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

@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 208
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 208
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

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
- Introduce back original extension functions (with nullable parameters) as deprecated
versions.
- Update .api dump
@bog-walk bog-walk force-pushed the bog-walk/inline-dsl-functions branch from d5f1d2c to 6e78edf Compare October 28, 2024 20:00
@bog-walk bog-walk merged commit ca1db70 into main Oct 28, 2024
5 checks passed
@bog-walk bog-walk deleted the bog-walk/inline-dsl-functions branch October 28, 2024 23:40
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