We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I want to use Exposed inside my framework but the definition of the column don't satisfy me. I want to add more information about a column.
A pattern info to satisfy before the insert/update for example:
object Users { val login = varchar("login", pattern="my regex validator", otherInfo =...) }
I can't do that
so now I make a class that hold a table instance.
But I can't do the same trick with column because if I create for example a custom column
class MyStringColumn(val col: Column<String, val pattern=""){ //some code here }
when I use the sql query api I need to write something like
val userId = Users.insert { it[Users.login.col] = "My login" } get Users.id
but it's ugly.
So my question is Can you make Column and why not Table open and any other answer are welcome.
Column
Table
Thanks
The text was updated successfully, but these errors were encountered:
You don't need to extend Column, ColumnType is a right way to do. Try this:
class RegexpString(private val pattern: String) : StringColumnType() { private val regexp = pattern.toRegex() override fun valueToDB(value: Any?): Any? { assert(value is String && regexp.matches(value)) { "$value doesn't match $pattern" } return super.valueToDB(value) } } fun Table.regexpString(name:String, pattern: String) = registerColumn<String>(name, RegexpString(pattern)) object Users : Table() { val login = regexpString("login", "pattern") }
Sorry, something went wrong.
that so nice, thanks. I close the issue
No branches or pull requests
I want to use Exposed inside my framework but the definition of the column don't satisfy me.
I want to add more information about a column.
A pattern info to satisfy before the insert/update for example:
I can't do that
so now I make a class that hold a table instance.
But I can't do the same trick with column
because if I create for example a custom column
when I use the sql query api I need to write something like
but it's ugly.
So my question is
Can you make
Column
and why notTable
openand any other answer are welcome.
Thanks
The text was updated successfully, but these errors were encountered: