-
Notifications
You must be signed in to change notification settings - Fork 229
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
Can't query for Instant #428
Comments
Yeah, type conversion is a recurring issue. I've put some thoughts together in #430 about how this might be tackled. My work there will be extended so that while a new |
You should be able to extend your Elide to support any custom conversions. public class MyElide extends Elide {
public MyElide(ElideSettings elideSettings) {
super(elideSettings);
elideSettings.getMapper().getObjectMapper()
.registerModule(new SimpleModule("instant", Version.unknownVersion())
.addSerializer(java.time.Instant.class, new JsonSerializer<java.time.Instant>() {
@Override
public void serialize(java.time.Instant instant,
JsonGenerator jsonGenerator,
SerializerProvider serializerProvider)
throws IOException, JsonProcessingException {
if (instant == null) {
jsonGenerator.writeNull();
} else {
jsonGenerator.writeObject(instant.toString());
}
}
}));
// initialize CoerceUtil, then register converter
CoerceUtil.coerce("", String.class);
ConvertUtils.register(new Converter() {
@Override
public <T> T convert(Class<T> type, Object value) {
return (T) java.time.Instant.parse(String.valueOf(value));
}
}, java.time.Instant.class);
} |
Hey @micheljung did you get a chance to look at @wcekan's suggestion? It would be interesting to know if it helped or not. |
Hi @clayreimann not yet but it's still relevant and I'll soon have to implement it :) It may take a few more weeks but I'll keep you updated. |
Hi, So I finally came around to test this. I added:
before creating Still, would be good if Elide integrates it as well, I guess :) Thanks for your work, much appreciated! |
@micheljung glad to hear this worked! :) I believe this isn't the default in Elide today because we thought it was sane to accept epoch values by default. However, maybe we could modify this module a bit and instead have something like this: ConvertUtils.register(new Converter() {
@Override
public <T> T convert(Class<T> type, Object value) {
if (value instanceof Number) {
return (T) java.time.Instant.ofEpochMilli(((Number) value).longValue());
}
return (T) java.time.Instant.parse(String.valueOf(value));
}
}, java.time.Instant.class); Would something like that be reasonable @wcekan? I would have to test and ensure not all values come in as In any case, thanks for reporting back! |
Resolved with Elide Serdes. Instead is supported. |
It seems like Elide doesn't properly convert String to Instant:
Filter was:
endTime=="2017-03-15T23:00:00Z"
(so it's RSQL)Seems to be a similar problem like #384
Also, if you could add support for
OffsetDateTime
andLocalDateTime
in the same run, that'd be awesome :-)The text was updated successfully, but these errors were encountered: