question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SchemaUtils.createMissingTablesAndColumns raise NoSuchElementException

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Tapaccommented, Oct 2, 2022

Should be solved in the next release

0reactions
Tapaccommented, 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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

0 - Stack Overflow
I'm using 0.22.1 Exposed libs (core/dao/jdbc) and when I use "SchemaUtils.createMissingTablesAndColumns", my tables are created but I get an ...
Read more >
[Bug] Regression in 0.22.1, createMissingTablesAndColumns ...
The code below works with exposed 0.21.1, but fails with 0.22.1. package org.user5145.champion.integration import com.zaxxer.hikari.
Read more >
JetBrains - Bountysource
I want to get the raw SQL query string that the database query builder above will generate. In this example, it would be...
Read more >
Kotlin Exposed - A lightweight SQL library - JDriven Blog
Kotlin Exposed provides a class SchemaUtils to create, drop, update tables ... createMissingTablesAndColumns(Actors, Movies, ActorsInMovies) ...
Read more >
Flutter-based mobile app displaying a list of daily curated ...
... b4cde5b Allow defining tables with quoted names (#1562); 070bff8 SchemaUtils.createMissingTablesAndColumns raise NoSuchElementException ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found