Menu

#46 Bad SQL generation for UNIONs

Current_SVN
open
nobody
DbModel (6)
5
2008-02-21
2008-02-21
No

The following query doesn't work with the DbModel:
SELECT ?attribute ?value WHERE {
{
<http://acme.com/foo#bar>
?attribute
?node
.
?node
<http://acme.com/bar#toMember>
?value .
} UNION {
<http://acme.com/foo#bar>
?attribute
?value .
}
}

It generates the following fatal error :
Uncaught exception 'Exception' with message 'ADOdb error: Unknown column 't0.predicate' in 'field list'

I looked at the generated SQL and there is definitely a problem:
SELECT
t0.predicate as "t0.value_v_attribute",
t1.object as "t1.value_v_value",
t1.object_is as "t1.is_v_value",
t1.l_language as "t1.lang_v_value",
t1.l_datatype as "t1.type_v_value"
...
FROM statements as t0 LEFT JOIN statements as t1
...
UNION
...
SELECT
t0.predicate as "t0.value_v_attribute",
t1.object as "t1.value_v_value",
t1.object_is as "t1.is_v_value",
t1.l_language as "t1.lang_v_value",
t1.l_datatype as "t1.type_v_value"
...
FROM statements as t1
...

The columns definitions should be different from one SELECT to the others.

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.