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

Error using optReference with refColumn #593

Closed
fracaron opened this issue Jul 1, 2019 · 2 comments
Closed

Error using optReference with refColumn #593

fracaron opened this issue Jul 1, 2019 · 2 comments
Labels

Comments

@fracaron
Copy link

fracaron commented Jul 1, 2019

I have tried to use optReference() for a nullable foreign key on Table but I get the following error:

Type parameter bound for T in fun <T : Comparable<T?>> optReference(name: String, refColumn: Column<T>, onDelete: ReferenceOption? = ..., onUpdate: ReferenceOption? = ...): Column<T?>
 is not satisfied: inferred type Int is not a subtype of Comparable<Int?>

As a workaround, I am using reference with nullable().

@Tapac
Copy link
Contributor

Tapac commented Jul 1, 2019

Could you provide a sample mapping which fails?

@Tapac Tapac added the bug label Jul 1, 2019
@fracaron
Copy link
Author

fracaron commented Jul 1, 2019

This is failling on optReference on RoleTable:

object ModuleTable: Table(name = "module") {
    val id = integer("id").autoIncrement().primaryKey()
    val name = varchar(name = "name", length = 125).uniqueIndex()
    val description = varchar("description", 125)
}

object RoleTable: Table(name = "role") {
    val id = integer("id").autoIncrement().primaryKey()
    val name = varchar("name", 125)
    val moduleId = optReference(
        name = "module_id",
        refColumn = ModuleTable.id,
        onDelete = ReferenceOption.CASCADE
    )

For now as a workaround, I can use something like:

object RoleTable: Table(name = "role") {
    val id = integer("id").autoIncrement().primaryKey().uniqueIndex()
    val name = varchar("name", 125)
    val description = varchar("description", 125)
    val moduleId = reference(
        name = "module_id",
        refColumn = ModuleTable.id,
        onDelete = ReferenceOption.CASCADE
    ).nullable()

@Tapac Tapac closed this as completed Jul 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants