The above works just fine with Lift 2.2. After upgrading to Lift 2.3 the id property remains set to None after the call to "save". Is that expected? Can I obtain the document id in some other way? And, of course, am I doing something wrong?val r = TestRecordMeta.createRecordr.text("blah")TestRecordMeta.save(r)println("text after save: " + r.text)println("id after save: " + r.id.is)println("Loading saved document...")val loaded = TestRecordMeta.fetch(r.id.is.get).open_!println("text after load: " + loaded.text.toString)
def handleUpdateResult(original: JObject)(json: JValue): Box[JObject] =for {obj <- Full(json).asA[JObject] ?~ ("update result is not a JObject: " + json)ok <- Full(json \ "ok" ).asA[JField].map(_.value).asA[JBool].filter(_.value) ?~ ("ok not present in reply or not true: "+json)id <- Full(json \ "id" ).asA[JField].map(_.value).asA[JString].map(_.s) ?~ ("id not present or not a string: " + json)rev <- Full(json \ "rev").asA[JField].map(_.value).asA[JString].map(_.s) ?~ ("rev not present or not a string: " + json)} yield updateIdAndRev(original, id, rev)
object TestRecordMeta extends TestRecord with CouchMetaRecord[TestRecord] {override def defaultDatabase = new Database("testrecord") {override def post(doc: JObject): Handler[Box[JObject]] = {(JSONRequest(this) <<# doc) ># handleUpdateResult(doc) _}def handleUpdateResult(original: JObject)(json: JValue): Box[JObject] = {for {obj <- Full(json).asA[JObject] ?~ ("update result is not a JObject: " + json)ok <- Full(json \ "ok" ).asA[JBool].filter(_.value) ?~ ("ok not present in reply or not true: "+json)id <- Full(json \ "id" ).asA[JString].map(_.s) ?~ ("id not present or not a string: " + json)rev <- Full(json \ "rev").asA[JString].map(_.s) ?~ ("rev not present or not a string: " + json)} yield updateIdAndRev(original, id, rev)}}}
Best,Hristo
On Wed, Apr 6, 2011 at 9:34 PM, Hristo Deshev <hri...@deshev.com> wrote:
Hi everyone,I've been trying to upgrade my app from Lift 2.2 to Lift 2.3 and I've been seeing some failures in my test suite. Here's what I found so far.I'm using lift-couchdb to save a bunch of documents to well... CouchDB. My code works in the following way:
- It creates a record object.
- It saves it to the db using the meta "save" method
- It then gets the newly-saved document id via the record.id property that has been populated by the "save" method.
Here's some code that looks mine:The above works just fine with Lift 2.2. After upgrading to Lift 2.3 the id property remains set to None after the call to "save". Is that expected? Can I obtain the document id in some other way? And, of course, am I doing something wrong?val r = TestRecordMeta.createRecordr.text("blah")TestRecordMeta.save(r)println("text after save: " + r.text)println("id after save: " + r.id.is)println("Loading saved document...")val loaded = TestRecordMeta.fetch(r.id.is.get).open_!println("text after load: " + loaded.text.toString)I have put up a reproduction project on github: https://github.com/hdeshev/lift-couchdb-id. It is set to use Lift 2.3. To quickly switch to Lift 2.2, edit project/build/Project.scala and change the liftVersion variable. Then ask sbt to reload, update, and run.Any help is much appreciated.Hristo
--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
...
Please open a ticket.
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code
on how should I do it then?
the code is not mine but from the person that opened the ticket, if he
declares that his code is on the public domain or something can it be
merged?
On Friday, November 4, 2011 at 12:41 AM, Mariano Guerra wrote:
On Fri, Nov 4, 2011 at 2:01 AM, Naftoli Gugenheim <nafto...@gmail.com> wrote:Unfortunately Lift doesn't except pull requests. DPP only takes code fromcommitters, since they signed a document about the intellectual property.on how should I do it then?
the code is not mine but from the person that opened the ticket, if hedeclares that his code is on the public domain or something can it bemerged?
ok, I will wait then.
thanks
I'll implement in the codebase with credits to Mariano and Hristo in the comment.
- Indrajit
NB: @Hristo, what's your Github handle?
> This has cascading awesomeness! Great analysis, nice fix and wonderful summary to back the fix.
>
> I'll implement in the codebase with credits to Mariano and Hristo in the comment.
>
> - Indrajit
>
> NB: @Hristo, what's your Github handle?
Nevermind, I found in the ticket description :)
- Indrajit