Project

General

Profile

« Previous | Next » 

Revision 5093

Added by Chris Jones over 14 years ago

QueryTerm.java will produce an incorrect SQL statement when there is an attribute in the XPath being used to search on. Regardless of the presence of the attribute, the clause:

(SELECT nodeid FROM xml_index WHERE path LIKE " + "'" + path + "') "

would be added to the query.

I've changed QueryTerm to conditionally add this clause, based on whether or not an attribute exists in the XPath.

View differences:

src/edu/ucsb/nceas/metacat/QueryTerm.java
284 284
                    if (!hasAttributeInPath(pathexpr)) {
285 285
                        // without attributes in path
286 286
                        self.append("AND parentnodeid IN ");
287
                        self.append(
288
                            "(SELECT nodeid FROM xml_index WHERE path LIKE "
289
                            + "'" + path + "') ");
287 290
                    } else {
288 291
                        // has a attribute in path
289 292
                        String attributeName = QuerySpecification
......
303 306
                            self.append("AND parentnodeid IN ");
304 307
                            path = QuerySpecification
305 308
                                .newPathExpressionWithOutAttribute(pathexpr);
309
                            self.append(
310
                                "(SELECT nodeid FROM xml_index WHERE path LIKE "
311
                                + "'" + path + "') ");
306 312
                        }
307 313
                    }
308
                    self.append(
309
                        "(SELECT nodeid FROM xml_index WHERE path LIKE "
310
                        + "'" + path + "') ");
311 314
                }
312 315
                else {
313 316
                    // without using XML Index; using nested statements instead

Also available in: Unified diff