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

override modifier in case class parameters causes mayhem #16

Open
allComputableThings opened this issue Apr 26, 2016 · 2 comments
Open

Comments

@allComputableThings
Copy link

allComputableThings commented Apr 26, 2016

def productToDocument(cc:Product)
    ...
    val values = cc.productIterator
    val fieldList = cc.getClass.getDeclaredFields.toList
    ...
    val purifiedFromId = values.zip(fieldList.iterator).toList.filter { case (v, f) => !isId(f.getName, cc.getClass) }

values and fieldList are not guaranteed to be the same length. Some values may be saved with incorrect field names.

For example:

  class TraceElement3( val date: Int )
  case class LoginEvent3(val userID: Int)
  case class TraceElementLoginEvent3( override val date: Int, val xx:String, val data: LoginEvent3 ) extends TraceElement3(date)

... the overridden value is hidden from the field list (two fields, three values).

Since loading matches fields to the document by case constructor's parameters, one solution to this is to look at the constructor's parameter list fieldList (and their annotations). This would also ensure reading and writing use the same policy to identify fields).

Am working on a fix for this.

@allComputableThings
Copy link
Author

Is now fixed in my fork.

@allComputableThings
Copy link
Author

Needs test cases. Will add.

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

1 participant