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

LocalDateTime #103

Closed
manuelbernhardt opened this issue Oct 9, 2013 · 5 comments
Closed

LocalDateTime #103

manuelbernhardt opened this issue Oct 9, 2013 · 5 comments

Comments

@manuelbernhardt
Copy link
Contributor

I'm trying to get the LocalDateTime type de/serialization to work, but am failing:

I am using Casbah 2.6.3 which has a method to register LocalDateTime conversions hooks (similar to DateTime). The LocalDateTime doesn't seem to be known by the transformers:

[error]     MatchError: 2013-10-09T11:29:21.667 (of class org.joda.time.LocalDateTime) (Injectors.scala:297)
[error] com.novus.salat.transformers.in.DateToJodaDateTime$class.transform(Injectors.scala:297)
[error] com.novus.salat.transformers.in.package$$anon$39.transform(Injectors.scala:223)
[error] com.novus.salat.transformers.Transformer$$anonfun$1.apply(Transformer.scala:85)
[error] com.novus.salat.transformers.Transformer$$anonfun$1.apply(Transformer.scala:85)
[error] com.novus.salat.transformers.Transformer.transform_$bang(Transformer.scala:85)
[error] com.novus.salat.Field.in_$bang(Field.scala:64)
[error] com.novus.salat.ConcreteGrater$$anonfun$5$$anonfun$apply$2.apply(Grater.scala:262)
[error] com.novus.salat.ConcreteGrater$$anonfun$5$$anonfun$apply$2.apply(Grater.scala:262)
[error] com.novus.salat.ConcreteGrater$$anonfun$5.apply(Grater.scala:262)
[error] com.novus.salat.ConcreteGrater$$anonfun$5.apply(Grater.scala:247)
[error] com.novus.salat.ConcreteGrater.asObject(Grater.scala:247)
[error] com.novus.salat.dao.SalatDAO$$anonfun$findOne$1.apply(SalatDAO.scala:348)

so I registered a custom one:

context.registerCustomTransformer(new CustomTransformer[org.joda.time.LocalDateTime, String]() {
  def deserialize(b: String): LocalDateTime = LocalDateTime.parse(b)

  def serialize(a: LocalDateTime): String = a.toString
})

But it does not seem to get picked up, i.e. the same trace appears.

I should mention that I am trying to map an Option[LocalDateTime]

@rktoomey
Copy link
Contributor

rktoomey commented Oct 9, 2013

Hi Manuel, there aren't any LocalDateTime tests in Salat at present. Does serializing a non-option LocalDateTime work?

@manuelbernhardt
Copy link
Contributor Author

Hi Rose,

after trying various things, I submitted a pull request for supporting the type directly in Salat, see #105.

The pull request just adds the handling and all the boilerplate for supporting it correctly.

It also bumps the Casbah version to 2.6.3 which includes conversion helpers for LocalDateTime - I am not entirely sure whether Salat would need those in order to function, however if I am not mistaken the helpers are useful when working directly with Casbah in a client application, so it is convenient to have them around.

@rktoomey
Copy link
Contributor

Thanks, Manuel. Merged and published as 1.9.4-SNAPSHOT for 2.10 (working on 2.9 backport right now).

Please test and I will release 1.9.4 as soon as I get a go-ahead from you and Gertjan in #104 , maybe tomorrow afternoon NY time?

@manuelbernhardt
Copy link
Contributor Author

Hi Rose,

thanks, I just tested this version, it works fine!

Manuel

On Thu, Oct 10, 2013 at 6:30 PM, Rose Toomey notifications@github.comwrote:

Thanks, Manuel. Merged and published as 1.9.4-SNAPSHOT for 2.10 (working
on 2.9 backport right now).

Please test and I will release 1.9.4 as soon as I get a go-ahead from you
and Gertjan in #104 https://github.com/novus/salat/issues/104 , maybe
tomorrow afternoon NY time?


Reply to this email directly or view it on GitHubhttps://github.com/novus/salat/issues/103#issuecomment-26069061
.

@rktoomey
Copy link
Contributor

1.9.4 is published!

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