Project

General

Profile

« Previous | Next » 

Revision 2459

Added by Chris Jones over 19 years ago

When a path expression includes element content and attribute content, then
the SQL generated needs to search for attribute nodetypes with parent
nodenames equal to the path expression element content. However, when
only searching for attribute content (such as just packageId), then
the parent sub-select needs to be omitted. This patch omits the parent
sub-select when the pathexpr starts with '
', './', or '../'.

This is a partial bug fix to:
http://bugzilla.ecoinformatics.org/show_bug.cgi?id=2052

View differences:

src/edu/ucsb/nceas/metacat/QueryTerm.java
189 189
            }
190 190
        }
191 191

  
192
        self.append("SELECT DISTINCT docid FROM xml_nodes WHERE \n");
192
        self.append("SELECT DISTINCT docid FROM xml_nodes WHERE ");
193 193
        self.append(searchexpr);
194 194
        if (pathexpr != null) {
195 195

  
......
204 204
                            .getAttributeName(pathexpr);
205 205
                    self.append("AND nodetype LIKE 'ATTRIBUTE' AND nodename LIKE '"
206 206
                                    + attributeName + "' ");
207
                    self.append("AND parentnodeid IN ");
208
                    pathexpr = QuerySpecification
209
                            .newPathExpressionWithOutAttribute(pathexpr);
207
                    // and the path expression includes element content other than
208
                    // just './' or '../' 
209
                    if ((!pathexpr.startsWith(QuerySpecification.ATTRIBUTESYMBOL)) && 
210
                        (!pathexpr.startsWith("./" + QuerySpecification.ATTRIBUTESYMBOL)) &&
211
                        (!pathexpr.startsWith("../" + QuerySpecification.ATTRIBUTESYMBOL))) {
210 212

  
213
                      self.append("AND parentnodeid IN ");
214
                      pathexpr = QuerySpecification
215
                                   .newPathExpressionWithOutAttribute(pathexpr);
216
                      self.append("(SELECT nodeid FROM xml_index WHERE path LIKE "
217
                                  + "'" + pathexpr + "') ");
218
                    }
211 219
                }
212
                self.append("(SELECT nodeid FROM xml_index WHERE path LIKE "
213
                        + "'" + pathexpr + "') ");
214 220
            } else {
215 221
                // without using XML Index; using nested statements instead
216 222
                self.append("AND parentnodeid IN ");

Also available in: Unified diff