Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Commit

Permalink
Merge pull request #59 from pmadrigal/feature/partialNOTfiler
Browse files Browse the repository at this point in the history
[CROSSDATA-160] [Mongo Datasource] Partial Not filter
  • Loading branch information
pmadrigal committed Nov 17, 2015
2 parents 20ccb39 + 5c645a7 commit 484b705
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Changelog

## 0.9.2 (November 2015)

* Partial NOT filter working

## 0.9.1 (November 2015)

* Bug fixed
* Refactor update _id on writer(_idField property not necessary)

## 0.9.0 (October 2015)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,13 @@ class MongodbReader(
MongoCredential.createCredential(user,database,password)},
config.get[MongodbSSLOptions](MongodbConfig.SSLOptions), config.properties.filterKeys(_.contains(MongodbConfig.ListMongoClientOptions))))

val emptyFilter = MongoDBObject(List())
val filter = Try(queryPartition(filters)).getOrElse(emptyFilter)

dbCursor = (for {
client <- mongoClient
collection <- Option(client(config(MongodbConfig.Database))(config(MongodbConfig.Collection)))
dbCursor <- Option(collection.find(queryPartition(filters), selectFields(requiredColumns)))
dbCursor <- Option(collection.find(filter, selectFields(requiredColumns)))
} yield {
mongoPartition.partitionRange.minKey.foreach(min => dbCursor.addSpecial("$min", min))
mongoPartition.partitionRange.maxKey.foreach(max => dbCursor.addSpecial("$max", max))
Expand Down Expand Up @@ -138,7 +141,6 @@ class MongodbReader(

queryBuilder.get
}

filtersToDBObject(filters)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ with ScalaBinaryVersion{
}
}

it should "manage the search fields and the update query, it has to read the same value from the search fields in " +
it should "manage the update fields and the update query, it has to read the same value from the fields in " +
"configuration" + scalaBinaryVersion in {
withEmbedMongoFixture(List()) { mongodbProc =>

Expand All @@ -230,17 +230,17 @@ with ScalaBinaryVersion{

import scala.collection.JavaConversions._

dbCursor.iterator().toList.forall { case obj: BasicDBObject =>
obj.getInt("att1") == 1
} should be (true)
dbCursor.iterator().toList.foreach{ case obj: BasicDBObject =>
obj.getInt("att1") should be (1)
}

mongodbBatchWriter.saveWithPk(dbUpdateIterator)

val dbCursor2 = dbCollection.find(MongoDBObject("att3" -> "holo"))

dbCursor2.iterator().toList.forall { case obj: BasicDBObject =>
obj.getInt("att1") == 2
} should be (true)
dbCursor2.iterator().toList.foreach { case obj: BasicDBObject =>
obj.getInt("att1") should be (2)
}

}
}
Expand Down

0 comments on commit 484b705

Please sign in to comment.