Comments (10)
Yes: sorry, options containing collections are not supported at present. They will be at some point in time, but....
Also, collections that contain options will be flattened when persisted.
from salat.
Thanks for the spec; I will try to look at it this weekend.
from salat.
Thanks, I appreciate it. I can certainly work around this, but figured it was worth reporting anyways.
from salat.
any update on this? It would be nice to have Optional collections as some fields may be optional for JSON.
from salat.
+1
from salat.
+1
from salat.
It seems unlikely that we are going to add support for optional collections Option[List[_]]
(why not just use an empty list)?
If you really need this, and replacing your optional collection Option[List[_]]
with just a List[_]
that is sometimes Nil
(or Map.empty
...or equivalent) - please take a crack at a pull request.
Also, I don't quite understand the case for Option[List[_]]
- can someone please elaborate why that type is necessary and just a List
isn't sufficient?
from salat.
Not that this can't be worked around, but a couple scenarios where Option[List[_]]
might be expected/preferred over List[_] = Nil
if you had a field that was being populated upstream by something like
Option(sourceDoc.fieldThatMightBeThere).map(extractValues)
to distinguish between cases where fieldThatMightBeThere
was/wasn't there, vs. cases where you might need to tweak your extractValues
functions or reevaluate assumptions about the content of the fieldThatMightBeThere
when it is there
or
if you have a big document with a ton of fields, but often only need a subset, say
case class Dictionary(
name: String,
author: String,
language: String,
everyWordInTheLanguage: Option[List[String]]
)
maybe i'm doing some aggregation on the authors of all my dictionaries, i'd project out the everyWordInTheLanguage
field, so the None
value there could be a signal of this field was projected out
as opposed to this field was asked for and was empty
I know these aren't insurmountable, but would be nice to have the . . .
(••)
( ••)>⌐■-■
(⌐■_■)
Option
P.S. Excited to see this project coming back to life!!
from salat.
I think empty list is the way to go. Thanks for the detailed explanation. You can close this if no-one objects.
from salat.
No hard objection, but i'd vote for keeping it around as a "nice to have"
from salat.
Related Issues (20)
- Custom TypeHint strategy for JSON HOT 2
- Unable to serialize case class hierarchy HOT 3
- mongo connection leak - re-use one mongo connection for each test DAO to reduce connection footprint. HOT 2
- Update Casbah to 2.8.2 in Salat 1.10.x to support connecting to Mongo 3.x server. HOT 16
- Play Salat HOT 4
- Project status update? HOT 23
- java.lang.ClassCastException when deserializing from Salat in context of akka runtime. HOT 4
- Error with reason "Very strange!" - GRATER GLITCH HOT 2
- Upgrade to sbt 0.13.12
- Release Salat 1.10 HOT 1
- JSON data can deserialize into collections containing data not matching the container generic type.
- More specific error class for Grater errors: SalatDeserializationException
- Release 1.11.x with Casbah 3.1.1 support (but not Scala 2.12) HOT 18
- Will this work with the latest Casbah 3.1.1? HOT 1
- SalatDAO support for collections HOT 7
- Scala 2.12 HOT 8
- Optional field in MongoDBObject with null value causing MatchError HOT 11
- Custom Transformers never get applied to case classes HOT 9
- Case class not serialising in order HOT 3
- Support for Mongo 3.6+ HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from salat.