Hey guys. For some reason I've not been able to re...
# exposed
c
Hey guys. For some reason I've not been able to resolve toOffsetDateTime:
Copy code
// Using exposed-kotlin-datetime (recommended)
Events.insert {
    it[scheduledAt] = Clock.System.now().toOffsetDateTime(TimeZone.UTC)
}
It seems
timestampWithTimeZone
will always expect java.time.OffsetDateTime Is there something I am missing?
t
Clock.System.now()
is kotlin.Instant therefore you should use
Clock.System.now().toJavaInstant().atOffset(ZoneOffset.UTC)
c
Hi @Cherrio LLC 👋 The only
toOffsetDateTime()
in the Exposed API is a method in the
OffsetDateTimeColumnType
class api ref. So it's not callable on a
kotlin.time.Instant
. Unless maybe you were referring to this
toOffsetDateTime()
from ZonedDateTime, I'd suggest trying the solution above.
c
Hi @Chantal Loncle I was just following the docs and I found that example. But I couldn't import
toOffsetDateTime()
Is the docs not correct in this case?
c
Ok I've found the docs you mean -> here. If so, yes there are issues in some of the code blocks and the one you've shared above is no longer correct, please ignore it. I've gone over the page and requested a full rehaul of the topic: EXPOSED-1037 <-- if you're interested in tracking or checking out the expected changes. Thanks for bringing this to our attention! thank you color
👍 1
c
Also @Chantal Loncle i dunno if i should report this here, But.. When generating migration script with the gradle plugin, can it skip classes instead of throw an error?? I experienced some errors like:
Copy code
Non-class container of a type parameter is not supported: private final java.lang.Object com.bertillon.handpay.domain.auth.GeneratedUserRepository.transaction(kotlin.jvm.functions.Function1,kotlin.coroutines.Continuation) (T)
or now:
Copy code
> A failure occurred while executing org.jetbrains.exposed.v1.gradle.plugin.GenerateMigrationsWorker
   > Type parameter not found: 0
I know i can group my tables in a package and point it there, but it makes it less flexible.
Ive narrowed it down to:
Copy code
UserTable.selectAll().map(::toEntity)
Kotlin reflect is unable to parse the metadata for
map
because of its generic parameter
c
Hmm, I can certainly look into skipping and logging output for any problem classes in a package. I'll spin up an example and bring it up with the team. But regarding your above statement: So you're saying that your
UserTable
is a basic standard Exposed table object (not a subclass etc). But because you have DSL queries and statements mixed into the same package, the plugin is attempting to parse these lines as table objects? I'll try to reproduce it and see what we an do on our end.
c
Yes. The table is in its own file. But classes under same packages with some generic functions throw up an error