[
https://issues.apache.org/jira/browse/METAMODEL-136?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14519111#comment-14519111
]
ASF GitHub Bot commented on METAMODEL-136:
------------------------------------------
Github user LosD commented on a diff in the pull request:
https://github.com/apache/metamodel/pull/21#discussion_r29324869
--- Diff:
mongodb/src/test/java/org/apache/metamodel/mongodb/MongoDbDataContextTest.java
---
@@ -490,4 +490,59 @@ public void run(UpdateCallback callback) {
dc.refreshSchemas();
assertEquals(0, defaultSchema.getTableCount());
}
+
+ public void testSelectWithLikeOperator() throws Exception {
+ if (!isConfigured()) {
+ System.err.println(getInvalidConfigurationMessage());
+ return;
+ }
+
+ DBCollection col = db.createCollection(getCollectionName(), null);
+
+ // delete if already exists
+ {
+ col.drop();
+ col = db.createCollection(getCollectionName(), null);
+ }
+
+ final BasicDBObject dbRow = new BasicDBObject();
+ dbRow.append("name", new BasicDBObject().append("first",
"John").append("last", "Doe"));
+ dbRow.append("gender", "MALE");
+ col.insert(dbRow);
+
+ final BasicDBObject dbRow2 = new BasicDBObject();
+ dbRow2.append("name", new BasicDBObject().append("first",
"Mary").append("last", "Johnson"));
+ dbRow2.append("gender", "FEMALE");
+ col.insert(dbRow2);
+
+ final BasicDBObject dbRow3 = new BasicDBObject();
+ dbRow3.append("name", new BasicDBObject().append("first",
"X").append("last", "Unknown"));
+ dbRow3.append("gender", "UNKNOWN");
+ col.insert(dbRow3);
+
+ final MongoDbDataContext dc = new MongoDbDataContext(db, new
SimpleTableDef(getCollectionName(), new String[] {
+ "name.first", "name.last", "gender", "addresses",
"addresses[0].city", "addresses[0].country",
+ "addresses[5].foobar" }));
+
+ final DataSet ds1 = dc.executeQuery("select * from my_collection
where gender LIKE '%MALE%'");
+ final DataSet ds2 = dc.executeQuery("select * from my_collection
where gender LIKE 'MALE%'");
+ final DataSet ds3 = dc.executeQuery("select * from my_collection
where gender LIKE '%NK%OW%'");
+ final DataSet ds4 = dc.executeQuery("select * from my_collection
where gender LIKE '%MALE'");
+ try {
+ assertTrue(ds1.next());
+ assertTrue(ds1.next());
+ assertFalse(ds1.next());
+ assertTrue(ds2.next());
+ assertFalse(ds2.next());
+ assertTrue(ds3.next());
+ assertFalse(ds3.next());
+ assertTrue(ds4.next());
+ assertTrue(ds4.next());
+ assertFalse(ds4.next());
+ } finally {
+ ds1.close();
+ ds2.close();
+ ds3.close();
+ }
--- End diff --
Pretty minor, but ds4 isn't closed.
> LIKE operator not supported in MongoDB module
> ---------------------------------------------
>
> Key: METAMODEL-136
> URL: https://issues.apache.org/jira/browse/METAMODEL-136
> Project: Apache MetaModel
> Issue Type: Bug
> Affects Versions: 4.3.2
> Reporter: Alberto
>
> The LIKE operator has not been included in the list of available operators.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)