You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@metamodel.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2016/05/24 08:33:12 UTC
[jira] [Commented] (METAMODEL-1088) Aliases do not work for MongoDB
modules
[ https://issues.apache.org/jira/browse/METAMODEL-1088?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15297897#comment-15297897 ]
ASF GitHub Bot commented on METAMODEL-1088:
-------------------------------------------
GitHub user ardlema opened a pull request:
https://github.com/apache/metamodel/pull/106
METAMODEL-1088 Find out aliases in columns
This PR includes the changes to fix METAMODEL-1088 by checking whether the columns contain aliases and if so just delegating the query to the QueryPostprocessDataContext.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/ardlema/metamodel METAMODEL-1088-fix-mongo-aliases
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/metamodel/pull/106.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #106
----
commit 59eb1d796543fcdae4115597ac58100e840f5c87
Author: Alberto Rodriguez <ar...@stratio.com>
Date: 2016-05-24T08:29:19Z
#METAMODEL-1088 Find out aliases in columns
----
> 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)