Comparing with fields of objects not retrieved in current Squeryl query results in NoSuchElementException
val theOne = from(one)(o => where (o.idField === "one") select (o)).head
val theMany = from(many)(m => where (m.oneId === theOne.idField) select(m))
Results in the exception because the implicit conversion that happens in RecordModeType doesn't know what to do with fields that have not been instrumented. Changing methods like:
implicit def long2ScalarLong(l: MandatoryTypedField[Long]) =
new SelectElementReference[LongType] (FieldReferenceLinker.takeLastAccessedFieldReference.get)(createOutMapperLongType) with NumericalExpression[Long]
to:
implicit def long2ScalarLong(l: MandatoryTypedField[Long]):
NumericalExpression[LongType] = FieldReferenceLinker.takeLastAccessedFieldReference match {
case Some(n: SelectElement) => new SelectElementReference[LongType](n)(createOutMapperLongType) with NumericalExpression[LongType]
case None => new ConstantExpressionNode[LongType](l.is) with NumericalExpression[LongType]
}
Should fix the problem. See: http://groups.google.com/group/liftweb/browse_thread/thread/efdd957d216e5c7d/14fdd12f22a0c8e3#14fdd12f22a0c8e3
val theMany = from(many)(m => where (m.oneId === theOne.idField) select(m))
Results in the exception because the implicit conversion that happens in RecordModeType doesn't know what to do with fields that have not been instrumented. Changing methods like:
implicit def long2ScalarLong(l: MandatoryTypedField[Long]) =
new SelectElementReference[LongType] (FieldReferenceLinker.takeLastAccessedFieldReference.get)(createOutMapperLongType) with NumericalExpression[Long]
to:
implicit def long2ScalarLong(l: MandatoryTypedField[Long]):
NumericalExpression[LongType] = FieldReferenceLinker.takeLastAccessedFieldReference match {
case Some(n: SelectElement) => new SelectElementReference[LongType](n)(createOutMapperLongType) with NumericalExpression[LongType]
case None => new ConstantExpressionNode[LongType](l.is) with NumericalExpression[LongType]
}
Should fix the problem. See: http://groups.google.com/group/liftweb/browse_thread/thread/efdd957d216e5c7d/14fdd12f22a0c8e3#14fdd12f22a0c8e3
Leave a comment
(In revision:39e9d8af5205fc9cd27b8ce29487b008fa4554f5) Bugfixes for squeryl-record: Index declaration and implicit conversions for fields of objects that are not retrieved in the current query
Closes #840
Closes #843
Added the traits SquerylRecordNumericalExpression and SquerylRecordNonNumericalExpression that are now mixed into the expressions returned
from the implicit conversions. With this trait, defineAs can be used instead of "is", which is ambiguous for record fields.
Moreover, the case that FieldReferenceLinker.takeLastAccessedFieldReference returns None is now handled correctly in the implicit conversions.
Added some test cases for showing that "defineAs" can be used instead of "is" in the schema declaration and that fields from
earlier retrieved records can be used in other expressions now.
There were also issues with Timestamp fields, which are resolved by using Timestamp instead of Date in the implicit conversion for DateTimeField.
Branch: master
Closes #840
Closes #843
Added the traits SquerylRecordNumericalExpression and SquerylRecordNonNumericalExpression that are now mixed into the expressions returned
from the implicit conversions. With this trait, defineAs can be used instead of "is", which is ambiguous for record fields.
Moreover, the case that FieldReferenceLinker.takeLastAccessedFieldReference returns None is now handled correctly in the implicit conversions.
Added some test cases for showing that "defineAs" can be used instead of "is" in the schema declaration and that fields from
earlier retrieved records can be used in other expressions now.
There were also issues with Timestamp fields, which are resolved by using Timestamp instead of Date in the implicit conversion for DateTimeField.
Branch: master