Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

It seems I had some issues with an older version of Squeryl 0.9.5 in …

…my ivy cache when I put together #1257.  This should fix any problems and get Jenkins building again.
  • Loading branch information...
commit 9c53f7e002bcf9d0d97f74aaf7ccd03afdd2050a 1 parent feb7cab
@davewhittaker davewhittaker authored
View
8 ...tence/squeryl-record/src/main/scala/net/liftweb/squerylrecord/RecordMetaDataFactory.scala
@@ -37,8 +37,8 @@ class RecordMetaDataFactory extends FieldMetaDataFactory {
def fieldFrom(mr: MetaRecord[_]): BaseField =
mr.asInstanceOf[Record[_]].fieldByName(name) match {
case Full(f: BaseField) => f
- case Full(_) => error("field " + name + " in Record metadata for " + clasz + " is not a TypedField")
- case _ => error("failed to find field " + name + " in Record metadata for " + clasz)
+ case Full(_) => org.squeryl.internals.Utils.throwError("field " + name + " in Record metadata for " + clasz + " is not a TypedField")
+ case _ => org.squeryl.internals.Utils.throwError("failed to find field " + name + " in Record metadata for " + clasz)
}
metaRecordsByClass get clasz match {
@@ -50,7 +50,7 @@ class RecordMetaDataFactory extends FieldMetaDataFactory {
metaRecordsByClass = metaRecordsByClass updated (clasz, mr)
fieldFrom(mr)
} catch {
- case ex => error("failed to find MetaRecord for " + clasz + " due to exception " + ex.toString)
+ case ex => org.squeryl.internals.Utils.throwError("failed to find MetaRecord for " + clasz + " due to exception " + ex.toString)
}
}
}
@@ -88,7 +88,7 @@ class RecordMetaDataFactory extends FieldMetaDataFactory {
case (_: LocaleTypedField) => classOf[String]
case (_: EnumTypedField[_]) => classOf[Int]
case (_: EnumNameTypedField[_]) => classOf[String]
- case _ => error("Unsupported field type. Consider implementing " +
+ case _ => org.squeryl.internals.Utils.throwError("Unsupported field type. Consider implementing " +
"SquerylRecordField for defining the persistent class." +
"Field: " + metaField)
}
View
24 persistence/squeryl-record/src/main/scala/net/liftweb/squerylrecord/RecordTypeMode.scala
@@ -154,19 +154,29 @@ trait RecordTypeMode extends PrimitiveTypeMode {
/** Conversion of mandatory Enum fields to Squeryl Expressions. */
implicit def enum2EnumExpr[EnumType <: Enumeration](f: MandatoryTypedField[EnumType#Value]) = fieldReference match {
- case Some(e) => new SelectElementReference[Enumeration#Value](e)(e.createEnumerationMapper) with EnumExpression[Enumeration#Value] with SquerylRecordNonNumericalExpression[Enumeration#Value]
+ case Some(e) => new SelectElementReference[Enumeration#Value](e)(e.createEnumerationMapper(f.defaultValue)) with EnumExpression[Enumeration#Value] with SquerylRecordNonNumericalExpression[Enumeration#Value]
case None => new ConstantExpressionNode[Enumeration#Value](f.is)(outMapperFromEnumValue(f.get)) with EnumExpression[Enumeration#Value] with SquerylRecordNonNumericalExpression[Enumeration#Value]
}
+
+ def reifySingleton[T](m: Manifest[T]) = {
+ val cls = m.erasure
+ val field = cls.getField("MODULE$")
+ field.get(null).asInstanceOf[T]
+ }
/** Conversion of optional Enum fields to Squeryl Expressions. */
- implicit def optionEnum2ScalaEnum[EnumType <: Enumeration](f: OptionalTypedField[EnumType#Value]) = fieldReference match {
- case Some(e) => new SelectElementReference[Option[Enumeration#Value]](e)(e.createEnumerationOptionMapper) with EnumExpression[Option[Enumeration#Value]] with SquerylRecordNonNumericalExpression[Option[Enumeration#Value]]
- case None => new ConstantExpressionNode[Option[Enumeration#Value]](f.is)(outMapperOptionFromOptionEnumValue(f.get) orNull) with EnumExpression[Option[Enumeration#Value]] with SquerylRecordNonNumericalExpression[Option[Enumeration#Value]]
- }
+ implicit def optionEnum2ScalaEnum[EnumType <: Enumeration](f: OptionalTypedField[EnumType#Value])(implicit m: Manifest[EnumType]) =
+ fieldReference match {
+ case Some(e) =>
+ new SelectElementReference[Option[Enumeration#Value]](e)(e.createEnumerationOptionMapper(Some(reifySingleton(m).values.iterator.next))) with EnumExpression[Option[Enumeration#Value]] with SquerylRecordNonNumericalExpression[Option[Enumeration#Value]]
+ case None =>
+ new ConstantExpressionNode[Option[Enumeration#Value]](f.is)(outMapperOptionFromOptionEnumValue(f.get) orNull) with EnumExpression[Option[Enumeration#Value]] with SquerylRecordNonNumericalExpression[Option[Enumeration#Value]]
+ }
/** Needed for outer joins. */
- implicit def optionEnumField2OptionEnum[EnumType <: Enumeration](f: Option[TypedField[EnumType#Value]]) = fieldReference match {
- case Some(e) => new SelectElementReference[Enumeration#Value](e)(e.createEnumerationMapper) with EnumExpression[Enumeration#Value] with SquerylRecordNonNumericalExpression[Enumeration#Value]
+ implicit def optionEnumField2OptionEnum[EnumType <: Enumeration](f: Option[TypedField[EnumType#Value]])(implicit m: Manifest[EnumType]) = fieldReference match {
+ case Some(e) =>
+ new SelectElementReference[Enumeration#Value](e)(e.createEnumerationMapper(reifySingleton(m).values.iterator.next)) with EnumExpression[Enumeration#Value] with SquerylRecordNonNumericalExpression[Enumeration#Value]
case None => new ConstantExpressionNode[Enumeration#Value](getValue(f).orNull)({
val enumOption = f flatMap { f1: TypedField[EnumType#Value] => f1.valueBox.toOption }
val outMapperOption: Option[OutMapper[Enumeration#Value]] = enumOption map { e: EnumType#Value => outMapperFromEnumValue(e) : OutMapper[Enumeration#Value] /*crashes scala 2.9.1 without explicit type */ }
Please sign in to comment.
Something went wrong with that request. Please try again.