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

Defer Foreign references during creation #384

Closed
chrisjenx opened this issue Sep 10, 2018 · 3 comments
Closed

Defer Foreign references during creation #384

chrisjenx opened this issue Sep 10, 2018 · 3 comments
Assignees
Labels

Comments

@chrisjenx
Copy link

chrisjenx commented Sep 10, 2018

Just found this out the hard way today. There are no deferred references.

Take two tables:

object Images : UUIDTable() {
    val name = varchar("name", 120)
    val fileName = varchar("file_name", 1024)
    val userId = uuid("user_id").references(Users.id)
}
object Users : UUIDTable("users") {

    val email = varchar("email", 256).uniqueIndex()
    val firstName = varchar("first_name", 256)
    val lastName = varchar("last_name", 256)

    // Profile Image
    val profileImageId = uuid("profile_image_id").references(Images.id, ReferenceOption.SET_NULL).nullable()

}

We can never create these two tables as the current create* methods will sort them based on table dependences (which is really good). But doesn't take into account tables that reference each other.

Not sure if it's a good approach, or not, but I'm wondering if all foreign references should be left to the end of the create() process so that the tables can be created first so that all foreign references can be created?

@Tapac Tapac self-assigned this Sep 12, 2018
@Tapac Tapac added the bug label Sep 12, 2018
@Wavesonics
Copy link

Just ran into this my self.

@Tapac
Copy link
Contributor

Tapac commented Sep 20, 2018

Fixed in master. Now it's possible to create cycle-referenced tables.

@chrisjenx
Copy link
Author

chrisjenx commented Sep 20, 2018 via email

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

3 participants