New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Morphia doesn't like semicolons in reduce clauses [moved] #432

Closed
jyemin opened this Issue Apr 25, 2013 · 1 comment

Comments

Projects
None yet
2 participants
@jyemin
Copy link
Contributor

jyemin commented Apr 25, 2013

This is Issue 432 moved from a Google Code project.
Added by 2012-09-28T15:23:59.000Z by m.huniew...@gmail.com.
Please review that bug for more context and additional comments, but update this bug.

Original labels: Type-Defect, Priority-Low

Original description

compile group: 'mysql', name: 'mysql-connector-java', version: '5.1.18'
compile group: 'org.mongodb', name: 'mongo-java-driver', version: '2.7.3'
compile group: 'com.google.code.morphia', name: 'morphia', version: '0.99'

There is no stack trace. All that I get is that result was null.

This works in MongoDb console but not in Morphia:

db.MongoDbSong.group(
    {key: {artistName: 1, albumName: 1},
    initial: {totalPlays: 0},
    reduce: function(obj, prev) { for(var i=0; i < obj.statsList.length; i++) { if(obj.statsList[i].libraryUuid == 'bf25ff51-da26-4c76-82dc-ada0e4a68c18'){ prev.totalPlays += obj.statsList[i].playCount}}}
})

This works in Morphia:

db.MongoDbSong.group(" +
    {key: {artistName: 1, albumName: 1},
    initial: {totalPlays: 0},
    reduce: function(obj, prev) {for each (var item in obj.statsList) if(item.libraryUuid == 'bf25ff51-da26-4c76-82dc-ada0e4a68c18'){ prev.totalPlays += item.playCount}}" +
  "});

The first one should work in Morphia as well. Not sure why it doesn't. Maybe it's the semicolons?

@evanchooly

This comment has been minimized.

Copy link
Member

evanchooly commented Mar 1, 2014

gone away

@evanchooly evanchooly closed this Mar 1, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment