[PATCH] Base: fix incorrect field removal in criterion inside query design view

Lionel Elie Mamane lionel at mamane.lu
Wed Dec 12 22:53:24 PST 2012

On Wed, Dec 12, 2012 at 10:53:07PM +0100, Olivier Ploton wrote:
> Problem: you cannot type a field name inside a criterion
> if the field name is also the column name, even if it is qualified.

> For example (see attached file: pairs.odb), 
> Query pairs_SQL can not be generated using query design view :
> Inside first column, named "name", typing in something like
>    < [Table_1].[name]
> or
>    < "Table_1"."name"
> inside a criterion leads to an error.

The "[Table_1].[name]" gets deleted. I see. The intention of this is that

 [Table_1].[name] < 'some value'

gets displayed as

 < 'some value'

Since the [Table_1].[name] is given by the rows above in the view.

There are actually two problems there:

1) the [Table_1].[name] should be deleted ONLY at the beginning of
   the expression, not later.

That's what your patch handles.

Small incremental improvement: use rString.isEmpty() instead of

Now, I'm uncertain if we should check "rString.isEmpty()" or
"i == m_aChildren.begin()". Maybe it is equivalent, but I'm not sure
yet. Since you have looked at this code more than I did at this point,
do you have an opinion?

2) The [Table_1].[name] should be deleted ONLY if it refers to the
   current column.

Currently *only* the column name is checked, not the source table.

I tried the attached patch, but it does not work, because it refers to
the original "real" table, and *not* to the *table* *alias* within the

Forget the reference to schema and/or catalog in my patch, that was
borne from the confusion between "real table" and "table instance in a

But currently we don't have property to refer to the "query table
name", that is the "table alias" in the query. My first thought was to
add such a property and populate it.


The rParam.xField ultimately comes from

        if (pWin)
            Reference<XNameAccess> xColumns =
            if (xColumns.is() && xColumns->hasByName(pEntry->GetField()))
                xColumns->getByName(pEntry->GetField()) >>= _rxColumn;

pWin is a OQueryTableWindow; getOriginalColumns() is implemented by the
base class OTableWindow, which has no notion of Table Alias. So it
seems that the "getOriginalColumns()" could be shared among all
instances (aliases) of the same table in query.

So my current thought is that we should add a "sTableAlias" member to
rParam, populate it in the code above, and pass it along down to
impl_parseNodeToString_throw, where it can use it instead of

Do you feel like you can look into this?

-------------- next part --------------
A non-text attachment was scrubbed...
Name: notworking.patch
Type: text/x-diff
Size: 3814 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20121213/ee806284/attachment.patch>

More information about the LibreOffice mailing list