[
https://issues.apache.org/jira/browse/JENA-1365?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16061878#comment-16061878
]
Claude Warren commented on JENA-1365:
-------------------------------------
Andy mentions that the FormatterElement method for ElementUnion shoudl read.
@Override
public void visit(ElementUnion el) {
if ( el.getElements().size() == 1 ) {
// If this is an element of just one, just do it in-place
return ;
}
....
I wonder if this is wise. QueryBuilder managed to build union-of-one queries
and nothing generates an error when one is created. If the formatter simply
removes it from the display but it still exists in the Element tree that is
executed how does a developer/user figure out that something is wrong or where
that something is.
It is unfortunate that there are no comment lines in SPARQL as then the
formatter could output the a message. :(
> QueryBuilder can build an invalid union-of-one query.
> -----------------------------------------------------
>
> Key: JENA-1365
> URL: https://issues.apache.org/jira/browse/JENA-1365
> Project: Apache Jena
> Issue Type: Bug
> Components: QueryBuilder
> Affects Versions: Jena 3.3.0
> Reporter: Claude Warren
> Assignee: Claude Warren
>
> From email chain betwen Claude and Andy
> is the union-of-one still legal during the construction of the query?
> Its illegal in a query - UNION is
> {..} UNION {..} UNION {..}
> The
> expected usage in the builder is:
> {noformat}
> builder.addUnion( <select-type-statement> ).addUnion(
> <select-type-statement>)
> {noformat}
> Currently the code builds a union-of-one and adds the next union to it.
> check to ensure that a union-of-one is not generated in the
> final result.
> At a minimum it an error to generate a union of one.
> So either, throw an expection or generate "{ pattern }" (including inside {})
> which is the moral equivalent.
> IMO The second is nicer. Tat is what I changed the formatter to do so at
> least it generated something even if it is changing the query a bit (round
> trip checking will fail but then it fails currently as it can't be parsed at
> all)
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)