[CDBI] Re: Class::DBI internal column swapping wierdness ? - possible resolution! (UNION DISTINCT)?

William Ross will at spanner.org
Thu Oct 6 11:10:43 BST 2005

On 6 Oct 2005, at 10:45, Richard Foley wrote:

> Hi
> I think I may have found the reason for this wierd behaviour, it  
> seems to come from a 'retrieve_from_sql' statement, when I use a  
> 'UNION DISTINCT' in the clause, something like this:
>         my $sql = qq|
>             name IN (
>                 SELECT name FROM task where shared = 'NO' AND  
> application = '$application'
>             )
>             UNION DISTINCT
>             SELECT * FROM task where shared = 'YES' AND application  
> IN (
>                 SELECT name FROM application WHERE container =  
> '$container'
>             )
>         |;
>         @tasks = Att::Task->retrieve_from_sql($sql);
> What seems to happen, is that the objects returned from the first  
> part of the SQL statement are expanded (or expandable), but the  
> ones which come back from the unioned (second) part of the  
> statement, are munged in a bad way.  On later inspection, they  
> appear to be a hash built from a list with an element missing or  
> added, so knocking all the key=>value pairs off by one, and messing  
> up the construction of the object, as you can see from the original  
> bug report (below).

That's a nasty looking query. Are we missing a bit at the beginning?

and it's worth asking: do both parts of the query return rows from  
the same table, and the same set of columns in each row?


More information about the ClassDBI mailing list