[
https://issues.apache.org/jira/browse/METAMODEL-1088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15303978#comment-15303978
]
ASF GitHub Bot commented on METAMODEL-1088:
-------------------------------------------
Github user albertostratio commented on the pull request:
https://github.com/apache/metamodel/pull/106#issuecomment-222129527
I agree @kaspersorensen. I've just pushed some changes to optimize the
query even though it contains aliases.
> Aliases do not work for MongoDB modules
> ---------------------------------------
>
> Key: METAMODEL-1088
> URL: https://issues.apache.org/jira/browse/METAMODEL-1088
> Project: Apache MetaModel
> Issue Type: Bug
> Affects Versions: 4.5.2
> Reporter: Alberto
> Priority: Minor
>
> Queries containing aliases do not work properly for MongoDB modules. The
> SelectItems of the returned dataset are not containing the aliases.
> See below a unit test that is currently failing:
> public void testSelectWithAlias() throws Exception {
> if (!isConfigured()) {
> System.err.println(getInvalidConfigurationMessage());
> return;
> }
> DBCollection col = db.createCollection(getCollectionName(), new
> BasicDBObject());
> // delete if already exists
> {
> col.drop();
> col = db.createCollection(getCollectionName(), new
> BasicDBObject());
> }
> final BasicDBObject dbRow = new BasicDBObject();
> dbRow.append("name", new BasicDBObject().append("first",
> "John").append("last", "Doe"));
> dbRow.append("gender", "MALE");
> col.insert(dbRow);
> 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 gender AS my_gender,
> name.first AS my_name from my_collection where gender LIKE '%MALE%'");
> final SelectItem[] selectItems = ds1.getSelectItems();
> SelectItem firstSelectItem = selectItems[0];
> SelectItem secondSelectItem = selectItems[1];
> try {
> assertNotNull(firstSelectItem.getAlias());
> assertNotNull(secondSelectItem.getAlias());
> } finally {
> ds1.close();
> }
> }
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)