{"action":"closed","issue":{"url":"https://api.github.com/repos/getquill/quill/issues/1207","repository_url":"https://api.github.com/repos/getquill/quill","labels_url":"https://api.github.com/repos/getquill/quill/issues/1207/labels{/name}","comments_url":"https://api.github.com/repos/getquill/quill/issues/1207/comments","events_url":"https://api.github.com/repos/getquill/quill/issues/1207/events","html_url":"https://github.com/getquill/quill/issues/1207","id":373853186,"node_id":"MDU6SXNzdWUzNzM4NTMxODY=","number":1207,"title":"quill-cassandra MappedEncoding (decode case) is not working as expected using driver LocalDate in some cases","user":{"login":"glammers1","id":13570903,"node_id":"MDQ6VXNlcjEzNTcwOTAz","avatar_url":"https://avatars0.githubusercontent.com/u/13570903?v=4","gravatar_id":"","url":"https://api.github.com/users/glammers1","html_url":"https://github.com/glammers1","followers_url":"https://api.github.com/users/glammers1/followers","following_url":"https://api.github.com/users/glammers1/following{/other_user}","gists_url":"https://api.github.com/users/glammers1/gists{/gist_id}","starred_url":"https://api.github.com/users/glammers1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glammers1/subscriptions","organizations_url":"https://api.github.com/users/glammers1/orgs","repos_url":"https://api.github.com/users/glammers1/repos","events_url":"https://api.github.com/users/glammers1/events{/privacy}","received_events_url":"https://api.github.com/users/glammers1/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-10-25T09:25:36Z","updated_at":"2018-11-14T02:40:32Z","closed_at":"2018-11-14T02:40:32Z","author_association":"NONE","body":"**Version**: 2.5.4\r\n**Module**: quill-cassandra\r\n**Database**: cassandra\r\n\r\n### Expected behavior\r\n\r\nCustom MappedEncoding for `org.joda.time.LocalDate` should work like the one already supported for `java.time.LocalDate` in [quill-cassandra](https://github.com/getquill/quill/blob/master/quill-cassandra/src/main/scala/io/getquill/context/cassandra/encoding/Encodings.scala)\r\n\r\n```scala\r\nimport com.datastax.driver.core.{LocalDate => CassandraDriverLocalDate}\r\nimport org.joda.time.LocalDate\r\n\r\nimplicit val encodeLocalDate: MappedEncoding[CassandraDriverLocalDate, LocalDate] =\r\n    MappedEncoding[CassandraDriverLocalDate, LocalDate](new LocalDate(_))\r\nimplicit val decodeLocalDate: MappedEncoding[LocalDate, CassandraDriverLocalDate] =\r\n    MappedEncoding[LocalDate, CassandraDriverLocalDate](ld =>\r\n      CassandraDriverLocalDate.fromYearMonthDay(ld.getYear, ld.getMonthOfYear, ld.getDayOfMonth))\r\n```\r\n\r\n### Actual behavior\r\n\r\nInsert (encode) works fine but read operation (decode) throws the following exception:\r\n\r\n```\r\njava.lang.IllegalArgumentException: No partial converter found for type: com.datastax.driver.core.LocalDate\r\n  org.joda.time.convert.ConverterManager.getPartialConverter(ConverterManager.java:253)\r\n  org.joda.time.LocalDate.<init>(LocalDate.java:415)\r\n  org.joda.time.LocalDate.<init>(LocalDate.java:363)\r\n  ammonite.$file.prueba_quill$X$.$anonfun$encodeLocalDate$1(prueba_quill.sc:17)\r\n  io.getquill.dsl.EncodingDsl.$anonfun$mappedBaseDecoder$1(EncodingDsl.scala:70)\r\n  io.getquill.dsl.EncodingDsl.$anonfun$mappedBaseDecoder$1$adapted(EncodingDsl.scala:70)\r\n  io.getquill.context.cassandra.encoding.Decoders$CassandraDecoder.apply(Decoders.scala:16)\r\n  ammonite.$file.prueba_quill$$anon$1.$anonfun$extract$1(prueba_quill.sc:46)\r\n  scala.collection.immutable.List.map(List.scala:283)\r\n  io.getquill.CassandraSyncContext.executeQuery(CassandraSyncContext.scala:40)\r\n  ammonite.$file.prueba_quill$.<init>(prueba_quill.sc:46)\r\n  ammonite.$file.prueba_quill$.<clinit>(prueba_quill.sc)\r\n```\r\n\r\n### Steps to reproduce the behavior\r\n\r\nI'm using [Ammonite](https://github.com/lihaoyi/ammonite) to reproduce the error. I've attached a zip with two files for both joda and java.time examples. \r\n\r\nFirst, create a C* keyspace \"test_quill\" with a table \"my_table\".\r\n\r\n```cql\r\nCREATE KEYSPACE test_quill\r\nWITH durable_writes = true\r\nAND replication = {\r\n\t'class' : 'SimpleStrategy',\r\n\t'replication_factor' : 1\r\n};\r\n\r\nCREATE TABLE test_quill.my_table (\r\n\tid date,\r\n\tPRIMARY KEY (id)\r\n);\r\n```\r\n\r\n* joda example with the error\r\n\r\n```scala\r\nimport $ivy.`io.getquill::quill-cassandra:2.5.4`\r\nimport $ivy.`io.getquill::quill-core:2.5.4`\r\nimport $ivy.`joda-time:joda-time:2.10`\r\nimport io.getquill._\r\nimport org.joda.time.LocalDate\r\nimport com.datastax.driver.core.Cluster.Builder\r\nimport com.datastax.driver.core.{Cluster, ConsistencyLevel, QueryOptions}\r\nimport com.datastax.driver.core.{LocalDate => CassandraDriverLocalDate}\r\n\r\nobject EncodersDecoders {\r\n  implicit val encodeLocalDate: MappedEncoding[CassandraDriverLocalDate, LocalDate] =\r\n    MappedEncoding[CassandraDriverLocalDate, LocalDate](new LocalDate(_))\r\n  implicit val decodeLocalDate: MappedEncoding[LocalDate, CassandraDriverLocalDate] =\r\n    MappedEncoding[LocalDate, CassandraDriverLocalDate](ld =>\r\n      CassandraDriverLocalDate.fromYearMonthDay(ld.getYear, ld.getMonthOfYear, ld.getDayOfMonth))\r\n}\r\n\r\nfinal case class MyTable(\r\n  id: LocalDate\r\n)\r\n\r\nval cassandraHost = \"localhost\"\r\nval keyspace = \"test_quill\"\r\n\r\nval cluster = Cluster.builder().addContactPoint(cassandraHost).build()\r\n\r\nval cassandraSyncContext = new CassandraSyncContext(SnakeCase, cluster, keyspace, 10)\r\nimport cassandraSyncContext._\r\n\r\nimport EncodersDecoders._\r\n\r\nval data =\r\n  MyTable(\r\n    new LocalDate(2016,1,2)\r\n  )\r\n\r\n// insert is ok\r\nrun(quote {\r\n  query[MyTable].insert(lift(data))\r\n})\r\n\r\n// the fail\r\nprintln(run(quote {\r\n  query[MyTable]\r\n}))\r\n```\r\n\r\n* java.time example works fine\r\n\r\n```scala\r\nimport $ivy.`io.getquill::quill-cassandra:2.5.4`\r\nimport $ivy.`io.getquill::quill-core:2.5.4`\r\nimport io.getquill._\r\nimport com.datastax.driver.core.Cluster.Builder\r\nimport com.datastax.driver.core.{Cluster, ConsistencyLevel, QueryOptions}\r\nimport java.time._\r\n\r\nfinal case class MyTable(\r\n  id: LocalDate\r\n)\r\n\r\nval cassandraHost = \"localhost\"\r\nval keyspace = \"test_quill\"\r\n\r\nval cluster = Cluster.builder().addContactPoint(cassandraHost).build()\r\n\r\nval cassandraSyncContext = new CassandraSyncContext(SnakeCase, cluster, keyspace, 10)\r\nimport cassandraSyncContext._\r\n\r\nval data =\r\n  MyTable(\r\n    LocalDate.of(1989, 11, 11)\r\n  )\r\n\r\n// ok\r\nrun(quote {\r\n  query[MyTable].insert(lift(data))\r\n})\r\n\r\n// ok\r\nprintln(run(quote {\r\n  query[MyTable]\r\n}))\r\n```\r\n\r\n### Workaround\r\n\r\nUse raw enconding for joda:\r\n\r\n```scala\r\nimport org.joda.time.LocalDate\r\nimport com.datastax.driver.core.{LocalDate => CassandraDriverLocalDate}\r\n\r\nimplicit val localDateDecoder: Decoder[LocalDate] =\r\n    decoder((index, row) => new LocalDate(row.getObject(index).toString))\r\nimplicit val localDateEncoder: Encoder[LocalDate] =\r\n    encoder(\r\n      (index, value, row) =>\r\n        row.setDate(\r\n          index,\r\n          CassandraDriverLocalDate.fromYearMonthDay(\r\n            value.getYear,\r\n            value.getMonthOfYear,\r\n            value.getDayOfMonth\r\n          )\r\n      )\r\n    )\r\n```\r\n\r\nWhy?\r\n\r\n[test_cases.zip](https://github.com/getquill/quill/files/2514166/test_cases.zip)\r\n\r\n@getquill/maintainers"}}
{"actor":{"display_login":"fwbrasil"}}