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 raise NoSuchElementException #1568

Closed
Komdosh opened this issue Aug 17, 2022 · 5 comments
Closed

Comments

@Komdosh
Copy link

Komdosh commented Aug 17, 2022

I deleted a field in MyFirstTableEntity then I try to restart the server and this exception appears

Code:

    val allTables = listOf(
            MyFirstTableEntity,
            MySecondTableEntity
        )

    transaction(db) {
        SchemaUtils.createMissingTablesAndColumns(*allTables.toTypedArray())
    }

Stacktrace:

java.util.NoSuchElementException: Key MY_FIRST_TABLE_ENTITY_COPY_4_0 is missing in the map.
	at kotlin.collections.MapsKt__MapWithDefaultKt.getOrImplicitDefaultNullable(MapWithDefault.kt:24)
	at kotlin.collections.MapsKt__MapsKt.getValue(Maps.kt:348)
	at org.jetbrains.exposed.sql.statements.jdbc.JdbcDatabaseMetadataImpl$tableConstraints$1$1.invoke(JdbcDatabaseMetadataImpl.kt:232)
	at org.jetbrains.exposed.sql.statements.jdbc.JdbcDatabaseMetadataImpl$tableConstraints$1$1.invoke(JdbcDatabaseMetadataImpl.kt:221)
	at org.jetbrains.exposed.sql.statements.jdbc.JdbcDatabaseMetadataImplKt.iterate(JdbcDatabaseMetadataImpl.kt:267)
	at org.jetbrains.exposed.sql.statements.jdbc.JdbcDatabaseMetadataImplKt.access$iterate(JdbcDatabaseMetadataImpl.kt:1)
	at org.jetbrains.exposed.sql.statements.jdbc.JdbcDatabaseMetadataImpl.tableConstraints(JdbcDatabaseMetadataImpl.kt:221)
	at org.jetbrains.exposed.sql.vendors.VendorDialect$fillConstraintCacheForTables$1.invoke(Default.kt:740)
	at org.jetbrains.exposed.sql.vendors.VendorDialect$fillConstraintCacheForTables$1.invoke(Default.kt:740)
	at org.jetbrains.exposed.sql.statements.jdbc.JdbcConnectionImpl.metadata(JdbcConnectionImpl.kt:63)
	at org.jetbrains.exposed.sql.Database.metadata$exposed_core(Database.kt:39)
	at org.jetbrains.exposed.sql.vendors.VendorDialect.fillConstraintCacheForTables(Default.kt:740)
	at org.jetbrains.exposed.sql.vendors.VendorDialect.columnConstraints(Default.kt:718)
	at org.jetbrains.exposed.sql.SchemaUtils.addMissingColumnsStatements(SchemaUtils.kt:223)
	at org.jetbrains.exposed.sql.SchemaUtils.createMissingTablesAndColumns(SchemaUtils.kt:318)
	at org.jetbrains.exposed.sql.SchemaUtils.createMissingTablesAndColumns$default(SchemaUtils.kt:306)
        .... my application calls here
@AlexeySoshin
Copy link
Contributor

@Komdosh Could you please provide the definitions of those entities, and which field have you deleted, so I could try and reproduce this?

@Tapac
Copy link
Contributor

Tapac commented Sep 9, 2022

@Komdosh , did you remove foreign key constraint as well?
Or you just remove mapping to the column?

@Komdosh
Copy link
Author

Komdosh commented Sep 13, 2022

@AlexeySoshin I can't really reproduce that
@Tapac I've just remove a mapping to the column

@Tapac
Copy link
Contributor

Tapac commented Sep 13, 2022

Looks like the problem is that Exposed located foreign key and can't find corresponding column in mapping. I'll take a look how it can be solved.

@Tapac
Copy link
Contributor

Tapac commented Oct 2, 2022

Should be solved in the next release

@Tapac Tapac closed this as completed Oct 2, 2022
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

3 participants