[MGNLCDEP-94] Update the search query Created: 23/Feb/17  Updated: 11/May/18  Resolved: 10/May/18

Status: Closed
Project: Content Dependencies
Component/s: None
Affects Version/s: 1.6.4, 1.7.1, 1.8
Fix Version/s: 1.7.2, 1.8.1

Type: Bug Priority: Neutral
Reporter: Ondrej Chytil Assignee: Robert Šiška
Resolution: Fixed Votes: 1
Labels: support
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: Text File MGNLCDEP-94.patch    
Issue Links:
relation
Template:
Patch included:
Yes
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:
Epic Link: Support
Sprint: Kromeriz 146
Story Points: 2

 Description   

The search query in info.magnolia.module.dependencies.impl.DefaultDependencies.getNodes(Node) fails if the page node name contains a dot followed by a number like:

select * from [nt:base] where ischildnode([/t.2]) and [jcr:primaryType] <> 'mgnl:page'

while the following statement works:

select * from [nt:base] where ischildnode('/t.2') and [jcr:primaryType] <> 'mgnl:page'

The statement pattern should be updated to use the quotation marks rather than square brackets:

String statement = String.format("select * from [nt:base] where ischildnode('%s') and [jcr:primaryType] <> '%s'", node.getPath(), node.getPrimaryNodeType().getName());


 Comments   
Comment by Thomas Duffey [ 23/Feb/17 ]

Also note same issue w/the second statement which uses isdescendentnode:

statement = String.format("select * from [nt:base] where isdescendantnode([%s])", child.getPath());
Comment by Frank Sommer [ 29/Mar/17 ]

Furthermore the queries does not work with some page node names beginning perhaps some with a number at beginning. In this case the following exception is logged and no results will be shown.

17-03-29 14:08:24 WARN  AUTHOR[http-bio-8001-exec-6]info.magnolia.module.dependencies.field.DependenciesField: Error getting references from node /test/en/12er:
javax.jcr.query.InvalidQueryException: Query:
select * from [nt:base] where ischildnode([/test/en/(*)12er]) and [jcr:primaryType] <> 'mgnl:page'
        at org.apache.jackrabbit.commons.query.sql2.Parser.getSyntaxError(Parser.java:978)
        at org.apache.jackrabbit.commons.query.sql2.Parser.getSyntaxError(Parser.java:959)
Comment by Ervin Vystup [ 31/Mar/17 ]

^^^ To Frank's comment
It occurs only if you use a name in the format "numberE". If it is "e" itself or "Enumber", it is working correctly. The letter "E" is the only letter which causes this behavior in the "Dependencies" tab.

Comment by Jan Haderka [ 05/Apr/18 ]

evystup so the 12er is issue, but 12re is not? Looks to me like e is taken to mean scientific notation of the number by formatter. If that is correct 12e2r would probably also work fine as it woudl conform to sci notation format.

 

ochytil can you confirm that your patch works also in cases where node name contains namespace? e.g. /mgnl:activated or /jcr:rep, /jcr:versionHistory etc. ? I believe that was the original reason for using square brackets.

Comment by Ervin Vystup [ 05/Apr/18 ]

had
12er and 12e2r are the issues
12re is ok

Comment by Thomas Duffey [ 27/Apr/18 ]

Possibly related tickets:

Seems very unclear when we're supposed to use square brackets, single quotes or both. I was able to patch my particular problem by changing from square brackets to single quotes or by keeping the square brackets but adding single quotes around the path within.

Generated at Mon Feb 12 00:12:29 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.