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

SchemaUtils.createMissingTablesAndColumns doesn't correctly check constraints in H2 #535

Closed
Smesharikable opened this issue Mar 26, 2019 · 0 comments

Comments

@Smesharikable
Copy link

The following test fails due to duplicated index2 constraint generation.

object H2UniqueConstraintsTests : DatabaseTestsBase() {

    @Test
    fun createTableWithMultipleIndexes() {
        withDb(TestDB.H2) {
            SchemaUtils.createMissingTablesAndColumns(MultipleIndexesTable)
        }
    }
    
    object MultipleIndexesTable: Table("H2_MULTIPLE_INDEXES") {
        val value1 = varchar("value1", 255)
        val value2 = varchar("value2", 255)

        init {
            uniqueIndex("index1", value1, value2)
            uniqueIndex("index2", value2, value1)
        }
    }
}

The problem is Exposed expected for each defined index (in terms if Exposed) there is a corresponding index in a database scheme, which is not always the true.
In the case above, two defined unique constraints are satisfied with a single generated index. So Queries.checkMissingIndices determines the index2 as missed and tried to add it one more time which resulting in error.

Tapac added a commit that referenced this issue Mar 30, 2019
…k constraints in H2

sqlite create unique index broken
@Tapac Tapac closed this as completed Mar 30, 2019
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

No branches or pull requests

2 participants