Looks like that did it. The test project works for me and successfully writes to the DB. I'll also give it a run with the full code I was working on and let you know if I run into any problems.
Thanks for the fast fix! Craig On Mar 4, 2010, at 3:47 PM, Ross Mellgren wrote: > Okay, type erasure ate your lunch. I have a patched version locally that > apparently works -- your code on my machine gets to "invalid username or > password" accessing Couch, which indicates it got past the previous problem. > > I'd love it if you could apply this patch to your local trunk and give it a > quick spin. If it works out for you, I'll get it into master, along with that > new enum field. > > -Ross > > diff --git > a/framework/lift-persistence/lift-couchdb/src/main/scala/net/liftweb/couchdb/JSONRecord.scala > > b/framework/lift-persistence/lift-couchdb/src/main/scala/net/liftweb/couchdb/JSONRecord.scala > index 1d9950b..c65c2fc 100644 > --- > a/framework/lift-persistence/lift-couchdb/src/main/scala/net/liftweb/couchdb/JSONRecord.scala > +++ > b/framework/lift-persistence/lift-couchdb/src/main/scala/net/liftweb/couchdb/JSONRecord.scala > @@ -20,7 +20,7 @@ import _root_.scala.collection.immutable.TreeSet > import _root_.scala.reflect.Manifest > import _root_.scala.xml.NodeSeq > import _root_.net.liftweb.common.{Box, Empty, Failure, Full} > -import Box.box2Iterable > +import Box.{box2Iterable, option2Box} > import _root_.net.liftweb.http.js.{JsExp, JsObj} > import _root_.net.liftweb.json.JsonParser > import _root_.net.liftweb.json.JsonAST.{JArray, JBool, JInt, JDouble, JField, > JNothing, JNull, JObject, JString, JValue} > @@ -307,9 +307,7 @@ class JSONSubRecordArrayField[OwnerType <: > JSONRecord[OwnerType], SubRecordType > > > /** Specialization of JSONField for field types that use some kind of encoded > string as the JSON type (e.g. binary data, datetimes) */ > -private[couchdb] trait JSONEncodedStringFieldMixin extends JSONField { > - self: Field[_, _] => > - > +private[couchdb] trait JSONEncodedStringFieldMixin[StorageType, OwnerType <: > Record[OwnerType]] extends JSONField with Field[StorageType, OwnerType] { > /** Encode the current value of the field as a JValue */ > def encode(value: MyType): String > > @@ -340,7 +338,7 @@ private[couchdb] trait JSONStringFieldMixin extends > JSONField { > > /** Binary data field for JSON records. Encodes as JString containing base64 > conversion of binary data. */ > class JSONBinaryField[OwnerType <: JSONRecord[OwnerType]](rec: OwnerType) > - extends BinaryField[OwnerType](rec) with JSONEncodedStringFieldMixin > + extends BinaryField[OwnerType](rec) with > JSONEncodedStringFieldMixin[Array[Byte], OwnerType] > { > def this(rec: OwnerType, value: Array[Byte]) = { this(rec); set(value) > } > def this(rec: OwnerType, value: Box[Array[Byte]]) = { this(rec); > setBox(value) } > @@ -381,7 +379,7 @@ class JSONCountryField[OwnerType <: > JSONRecord[OwnerType]](rec: OwnerType) > > /** Date/time data field for JSON records. Encodes as JString containing the > internet formatted datetime */ > class JSONDateTimeField[OwnerType <: JSONRecord[OwnerType]](rec: OwnerType) > - extends DateTimeField[OwnerType](rec) with JSONEncodedStringFieldMixin > + extends DateTimeField[OwnerType](rec) with > JSONEncodedStringFieldMixin[Calendar, OwnerType] > { > def this(rec: OwnerType, value: Calendar) = { this(rec); set(value) } > def this(rec: OwnerType, value: Box[Calendar]) = { this(rec); setBox(value) > } > @@ -396,7 +394,7 @@ class JSONDateTimeField[OwnerType <: > JSONRecord[OwnerType]](rec: OwnerType) > > /** Decimal data field for JSON records. Encodes as a JString, to preserve > decimal points (JDouble being lossy) */ > class JSONDecimalField[OwnerType <: JSONRecord[OwnerType]](rec: OwnerType, > context: MathContext, scale: Int) > - extends DecimalField[OwnerType](rec, context, scale) with > JSONEncodedStringFieldMixin > + extends DecimalField[OwnerType](rec, context, scale) with > JSONEncodedStringFieldMixin[BigDecimal, OwnerType] > { > def this(rec: OwnerType, value: BigDecimal) = { this(rec, > MathContext.UNLIMITED, value.scale); set(value) } > def this(rec: OwnerType, value: Box[BigDecimal], scale: Int) = { this(rec, > MathContext.UNLIMITED, scale); setBox(value) } > > > > On Mar 4, 2010, at 2:29 PM, Craig Blake wrote: > >> Great, thanks for taking the time to look into it! >> >> Craig >> >> On Mar 4, 2010, at 2:23 PM, Ross Mellgren wrote: >> >>> I can reproduce this locally, and offhand looks like a scala compiler bug >>> (this should never have compiled). >>> >>> I have to run right now, but I'll look at in ~2-4 hours and hopefully >>> figure it out for you. >>> >>> -Ross >>> >>> On Mar 4, 2010, at 1:28 PM, Craig Blake wrote: >>> >>>> To test further, I've created a simple test project with only one >>>> dependency, lift-couchdb, and this code: >>>> >>>> object Settings extends Settings with CouchMetaRecord[ Settings] >>>> class Settings extends CouchRecord[ Settings] { >>>> def meta = Settings >>>> object updated extends JSONDateTimeField( this) >>>> } >>>> >>>> object Testing { >>>> >>>> def main( args: Array[ String]) { >>>> import CouchDB.defaultDatabase >>>> defaultDatabase = new Database( :/( "localhost", 5984) as_! ( >>>> "username", "password"), "database") >>>> >>>> val settings = Settings.createRecord >>>> settings.updated( Calendar.getInstance( TimeZone.getTimeZone( >>>> "UTC"))) >>>> settings.save >>>> } >>>> } >>>> >>>> I get the same error: >>>> >>>> java.lang.AbstractMethodError: >>>> test.Settings$updated$.encode(Ljava/lang/Object;)Ljava/lang/String; >>>> >>>> I've also put the test code in Github in case anyone might be able to >>>> reproduce it locally: >>>> >>>> g...@github.com:craigwblake/lift-couchdb-test.git >>>> >>>> >>>> Thanks, >>>> Craig > > -- > You received this message because you are subscribed to the Google Groups > "Lift" group. > To post to this group, send email to lift...@googlegroups.com. > To unsubscribe from this group, send email to > liftweb+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/liftweb?hl=en. > -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.