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

fix(core): serialize duration as strings #5630

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public static ObjectMapper ofIon() {
private static ObjectMapper configure(ObjectMapper mapper) {
return mapper
.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
.configure(SerializationFeature.WRITE_DURATIONS_AS_TIMESTAMPS, false)
.setSerializationInclusion(JsonInclude.Include.NON_NULL)
.registerModule(new JavaTimeModule())
.registerModule(new Jdk8Module())
Expand Down
3 changes: 1 addition & 2 deletions core/src/test/java/io/kestra/plugin/core/kv/SetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,7 @@ void typeSpecified() throws Exception {
assertThat(kv.getValue(TEST_KEY).get().value(), is(Instant.parse("2023-05-02T01:02:03Z")));

set.toBuilder().value("P1DT5S").kvType(KVType.DURATION).build().run(runContext);
// TODO Hack meanwhile we handle duration serialization as currently they are stored as bigint...
assertThat((long) Double.parseDouble(kv.getValue(TEST_KEY).get().value().toString()), is(Duration.ofDays(1).plus(Duration.ofSeconds(5)).toSeconds()));
assertThat(kv.getValue(TEST_KEY).get().value(), is(Duration.ofDays(1).plus(Duration.ofSeconds(5))));

set.toBuilder().value("[{\"some\":\"value\"},{\"another\":\"value\"}]").kvType(KVType.JSON).build().run(runContext);
assertThat(kv.getValue(TEST_KEY).get().value(), is(List.of(Map.of("some", "value"), Map.of("another", "value"))));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table executions drop column "state_duration";
alter table executions add column "state_duration" VARCHAR(150) NOT NULL GENERATED ALWAYS AS (JQ_STRING("value", '.state.duration'));
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table `executions` drop column `state_duration`;
alter table `executions` add column `state_duration` VARCHAR(150) NOT NULL GENERATED ALWAYS AS (value ->> '$.state.duration'):
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table executions drop column state_duration;
alter table executions add column state_duration VARCHAR(150) NOT NULL GENERATED ALWAYS AS (value #>> '{state, duration}');
Loading