Skip to content

Commit

Permalink
fixed wrong sql query generation in refObjectMap
Browse files Browse the repository at this point in the history
Check sql query for "order by" keyword before inserting "where"
condition in refObjectMap definitions with a joinCondition
  • Loading branch information
nkons committed Dec 2, 2013
1 parent b3c93ae commit bf5aa4b
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/main/java/gr/seab/r2rml/beans/Generator.java
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,13 @@ public void createTriples(MappingDocument mappingDocument) {
String parentFieldName = predicateObjectMap.getRefObjectMap().getParent();
if (!databaseType.equals("postgresql")) parentFieldName = parentFieldName.replaceAll("\"", ""); //in mysql, table names must not be enclosed in quotes
String addition = " WHERE " + parentFieldName + " = " + childValue;
parentQuery += addition;
int order = parentQuery.toUpperCase().indexOf("ORDER BY");
if (order != -1) {
String orderCondition = parentQuery.substring(order);
parentQuery = parentQuery.substring(0, order) + addition + " " + orderCondition;
} else {
parentQuery += addition;
}
} else {
log.error("In the logical table mapping <" + logicalTableMapping.getUri() + ">, the SQL query that generates the parent triples in the parent logical table mapping <" + l.getUri() + "> contains results from more than one tables. " +
" Consider using rr:tableName instead of rr:sqlQuery in the parent logical table mapping. Terminating.");
Expand Down

0 comments on commit bf5aa4b

Please sign in to comment.