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 >> >> >> On Mar 3, 2010, at 9:54 PM, Naftoli Gugenheim wrote: >> >>> AbstractMethodError means you need to do a clean build and make sure you >>> don't have multiple scala versions. >>> >>> ------------------------------------- >>> Craig Blake<craigwbl...@gmail.com> wrote: >>> >>> Just took a minor change to compile (didn't like ?~) and I'll let you know >>> how it goes soon. I'm running into one more problem, this time a runtime >>> exception saving a document: >>> >>> java.lang.AbstractMethodError: >>> test.Settings$updated$.encode(Ljava/lang/Object;)Ljava/lang/String; >>> at >>> net.liftweb.couchdb.JSONEncodedStringFieldMixin$$anonfun$asJValue$6.apply(JSONRecord.scala:319) >>> at >>> net.liftweb.couchdb.JSONEncodedStringFieldMixin$$anonfun$asJValue$6.apply(JSONRecord.scala:319) >>> at net.liftweb.common.Full.map(Box.scala:330) >>> at net.liftweb.couchd... >>> >>> >>> The field is defined as: >>> >>> object updated extends JSONDateTimeField( this) >>> >>> Surely something else I missed? >>> >>> Craig >>> >>> On Mar 3, 2010, at 8:39 PM, Ross Mellgren wrote: >>> >>>> Try this: >>>> >>>> /** Enum data field for JSON records. Encodes as JString */ >>>> class JSONEnumNameField[OwnerType <: JSONRecord[OwnerType], EnumType <: >>>> Enumeration] >>>> (rec: OwnerType, enum: EnumType)(implicit >>>> enumValueType: Manifest[EnumType#Value]) >>>> extends EnumField[OwnerType, EnumType](rec, enum) with JSONField >>>> { >>>> def this(rec: OwnerType, enum: EnumType, value: EnumType#Value)(implicit >>>> enumValueType: Manifest[EnumType#Value]) = { >>>> this(rec, enum) >>>> set(value) >>>> } >>>> >>>> def this(rec: OwnerType, enum: EnumType, value: >>>> Box[EnumType#Value])(implicit enumValueType: Manifest[EnumType#Value]) = { >>>> this(rec, enum) >>>> setBox(value) >>>> } >>>> >>>> def asJValue: JValue = valueBox.map(v => JString(v.toString)) openOr >>>> (JNothing: JValue) >>>> def fromJValue(jvalue: JValue): Box[EnumType#Value] = jvalue match { >>>> case JNothing|JNull if optional_? => setBox(Empty) >>>> case JString(s) => setBox(enum.valueOf(s) ?~ ("Unknown >>>> value \"" + s + "\"")) >>>> case other => setBox(expectedA("JString", other)) >>>> } >>>> } >>>> >>>> Let me know if it works for you. If so, I'll start the process of getting >>>> it into master as soon as I can. >>>> >>>> -Ross >>>> >>>> On Mar 3, 2010, at 8:12 PM, Craig Blake wrote: >>>> >>>>> Sure, will do. The only thing I think I'll need to figure out is how to >>>>> persist an enumeration by name rather than ordinal value, but I imagine >>>>> that it should be pretty straight-forward to add a new field type in my >>>>> app to handle it. >>>>> >>>>> Thanks, >>>>> Craig >>>>> >>>>> On Mar 3, 2010, at 7:45 PM, Ross Mellgren wrote: >>>>> >>>>>> It's no problem, as I mentioned the compiler error is practically >>>>>> useless. >>>>>> >>>>>> Hope you get along well, let me know if you have any other issues. >>>>>> >>>>>> -Ross >>>>>> >>>>>> On Mar 3, 2010, at 7:29 PM, Craig Blake wrote: >>>>>> >>>>>>> Yep, that seems to be better. Sorry for the noise, I don't know why I >>>>>>> didn't think to check that. >>>>>>> >>>>>>> Thanks for the quick answer. >>>>>>> >>>>>>> Craig >>>>>>> >>>>>>> On Mar 3, 2010, at 4:44 PM, Ross Mellgren wrote: >>>>>>> >>>>>>>> Unfortunately the compiler error is bizarre (due to some of the type >>>>>>>> shuffling involved), but the underlying problem you're experiencing is >>>>>>>> that DateTimeFields (and therefore JSONDateTimeFields) have a storage >>>>>>>> type of Calendar, and you're trying to assign a Date to them. Try >>>>>>>> Calendar.getInstance instead of new Date() and see if that resolves it >>>>>>>> for you? >>>>>>>> >>>>>>>> -Ross >>>>>>>> >>>>>>>> On Mar 3, 2010, at 4:32 PM, Craig Blake wrote: >>>>>>>> >>>>>>>>> Hi, >>>>>>>>> >>>>>>>>> I am getting familiar with the lift-couchdb module, and trying to put >>>>>>>>> together a sample based on the tests in the module. Trying to create >>>>>>>>> a record, based on this test code: >>>>>>>>> >>>>>>>>> def testRec1: Person = Person.createRecord.name("Alice").age(25) >>>>>>>>> >>>>>>>>> this is what I have: >>>>>>>>> >>>>>>>>> class Account extends CouchRecord[Account] { >>>>>>>>> def meta = Account >>>>>>>>> object created extends JSONDateTimeField(this) >>>>>>>>> } >>>>>>>>> object Account extends Account with CouchMetaRecord[Account] >>>>>>>>> >>>>>>>>> ... >>>>>>>>> >>>>>>>>> val account = Account.createRecord.created(new Date()) >>>>>>>>> >>>>>>>>> >>>>>>>>> I get a compilation error: >>>>>>>>> >>>>>>>>> [WARNING] Test.scala:44: error: overloaded method value apply with >>>>>>>>> alternatives ((net.liftweb.common.Box[_12.MyType])test.Account) >>>>>>>>> forSome { val _12: object test.Account#created } <and> >>>>>>>>> ((_13.MyType)test.Account) forSome { val _13: object >>>>>>>>> test.Account#created } cannot be applied to (java.util.Date) >>>>>>>>> [WARNING] val account = Account.createRecord.created( new >>>>>>>>> Date()) >>>>>>>>> >>>>>>>>> >>>>>>>>> I'm sure that I am just missing something obvious. Any ideas what? >>>>>>>>> >>>>>>>>> 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. >>>>>>>> >>>>>>> >>>>>>> -- >>>>>>> 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. >>>>>> >>>>> >>>>> -- >>>>> 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. >>>> >>> >>> -- >>> 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. >>> >> >> -- >> 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. > -- 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.