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

Allow transform() to be called outside of entity class #1146

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jnfeinstein
Copy link
Contributor

This function does not require an EntityClass to accomplish the transform. Placing this outside of the EntityClass allows consumers to define transforms as extension functions. For example:

fun Column<Int>.asString() = transform({ it.toString() }, { it.toInt() })

This can then be used as:

object FooTable : Table("foo") {
  val number = integer("number").asString()
}

This function does not require an `EntityClass` to accomplish the
transform.  Placing this outside of the `EntityClass` allows consumers
to define transforms as extension functions.  For example:
```
fun Column<Int>.asString() = transform({ it.toString() }, { it.toInt() })
```
This can then be used as:
```
object FooTable : Table("foo") {
  val number = integer("number").asString()
}
```
@Tapac
Copy link
Contributor

Tapac commented Aug 2, 2021

Hi @jnfeinstein , thank you for a PR, can you please add the test for a new function as I'm not sure that using that column in pure DSL style will works well.

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.

None yet

2 participants