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

Entity created with default timestamp is null #2412

Open
fabianloewe opened this issue Feb 18, 2025 · 2 comments
Open

Entity created with default timestamp is null #2412

fabianloewe opened this issue Feb 18, 2025 · 2 comments

Comments

@fabianloewe
Copy link

fabianloewe commented Feb 18, 2025

I have the following table:

object MyTable : LongIdTable() {
    // ...
    val created = timestamp("created").defaultExpression(CurrentTimestamp).databaseGenerated()
    val modified = timestamp("modified").defaultExpression(CurrentTimestamp).databaseGenerated()
    // ...
}

and the following entity:

class MyEntity(id: EntityID<Long>) : LongEntity(id) {
    companion object : LongEntityClass<MyEntity>(MyTable)

    // ...
    val created by MyTable.created
    var modified by MyTable.modified
    // ...
}

Now, if I create the entity with:

val obj = MyEntity.new {
    // All properties are initialized except created and modified
}

// Fails
assertNotNull(obj.created)

But in the IDEA debugger, if I click on the property, it shows the Instant object that has been created in the database.
If I run into the assertion after clicking the property, the assertion doesn't fail anymore.
How is that possible?

@constructivetim
Copy link

Can confirm that this breaking change was introduced in 0.57. everything works as it should in 0.56. I believe the title of the bug report should be

"Timestamps are no longer defaulting since 0.57"

@constructivetim
Copy link

to be fair, this breaking issue is documented here: https://www.jetbrains.com/help/exposed/breaking-changes.html#0-57-0

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