[Libreoffice-commits] core.git: 5 commits - dbaccess/source wizards/com

Lionel Elie Mamane lionel at mamane.lu
Fri Aug 2 04:58:45 PDT 2013


 dbaccess/source/core/api/SingleSelectQueryComposer.cxx |   32 +++++++++++------
 wizards/com/sun/star/wizards/db/SQLQueryComposer.java  |    3 -
 2 files changed, 23 insertions(+), 12 deletions(-)

New commits:
commit 3d5a27bf5a50870adce0bd43f9f71211e9caaac2
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Fri Aug 2 12:10:57 2013 +0200

    for later...
    
    Change-Id: I266d2992bcd212a6539e4b50c9daf2c53ff98904

diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index b1270f0..9143aff 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -1591,6 +1591,9 @@ void OSingleSelectQueryComposer::setConditionByColumn( const Reference< XPropert
     const OUString aQuote    = m_xMetaData->getIdentifierQuoteString();
     getColumns();
 
+    // TODO: if this is called for HAVING, check that the column is a GROUP BY column
+    //       or that it is an aggregate function
+
     if ( m_aCurrentColumns[SelectColumns] && m_aCurrentColumns[SelectColumns]->hasByName(aName) )
     {
         Reference<XPropertySet> xColumn;
commit a8f327a9fc13fe5d0992aba4d217b8c909871237
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Fri Aug 2 12:10:25 2013 +0200

    make comment actually describe the code
    
    Change-Id: If4dda13ff8018d7fd855457a76db2acf8077a477

diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index c77c2b6..b1270f0 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -1353,7 +1353,8 @@ OUString OSingleSelectQueryComposer::getTableAlias(const Reference< XPropertySet
         {
             aComposedName = ::dbtools::composeTableName( m_xMetaData, aCatalog, aSchema, aTable, sal_False, ::dbtools::eInDataManipulation );
 
-            // first check if this is the table we want to or has it a tablealias
+            // Is this the right case for the table name?
+            // Else, look for it with different case, if applicable.
 
             if(!m_pTables->hasByName(aComposedName))
             {
commit 0fafb92e97855c4f5e461c6198d92b41431b1227
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Fri Aug 2 12:09:53 2013 +0200

    janitorial: more const where possible
    
    Change-Id: If579b2b2990c3cdd4785077aa1b34c33bcc241b6

diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index cb65b4b..c77c2b6 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -1332,8 +1332,8 @@ OUString OSingleSelectQueryComposer::getTableAlias(const Reference< XPropertySet
         column->getPropertyValue(PROPERTY_NAME)         >>= aColumnName;
 
         Sequence< OUString> aNames(m_pTables->getElementNames());
-        const OUString* pBegin   = aNames.getConstArray();
-        const OUString* pEnd     = pBegin + aNames.getLength();
+        const OUString* pBegin     = aNames.getConstArray();
+        const OUString* const pEnd = pBegin + aNames.getLength();
 
         if(aTable.isEmpty())
         { // we haven't found a table name, now we must search every table for this column
commit 6fc71eea1d11d0d373ad32052d25f65e800509e7
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Fri Aug 2 12:08:16 2013 +0200

    SingleSelectQueryComposer: the name of a non-SELECT column is its "real" name
    
    That is, the name in the table.
    
    Change-Id: I95326915f381ec0cf72c66f13352ce76d82e9517

diff --git a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
index 58a5564..cb65b4b 100644
--- a/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
+++ b/dbaccess/source/core/api/SingleSelectQueryComposer.cxx
@@ -541,21 +541,29 @@ OUString OSingleSelectQueryComposer::impl_getColumnName_throw(const Reference< X
             throw SQLException(DBACORE_RESSTRING(RID_STR_COLUMN_NOT_VALID),*this,SQLSTATE_GENERAL,1000,makeAny(aErr) );
         }
 
-    OUString aName, aNewName;
+    OUString aName;
     column->getPropertyValue(PROPERTY_NAME)         >>= aName;
 
+    const OUString aQuote  = m_xMetaData->getIdentifierQuoteString();
+
+    if ( m_aCurrentColumns[SelectColumns] &&
+         m_aCurrentColumns[SelectColumns]->hasByName(aName) )
+    {
+        // It is a column from the SELECT list, use it as such.
+        return ::dbtools::quoteName(aQuote,aName);
+    }
+
+    // Nope, it is an unrelated column.
+    // Is that supported?
     if ( bOrderBy &&
-         !m_xMetaData->supportsOrderByUnrelated() &&
-         m_aCurrentColumns[SelectColumns] &&
-         !m_aCurrentColumns[SelectColumns]->hasByName(aName) )
+         !m_xMetaData->supportsOrderByUnrelated() )
     {
         OUString sError(DBACORE_RESSTRING(RID_STR_COLUMN_MUST_VISIBLE));
         throw SQLException(sError.replaceAll("%name", aName),*this,SQLSTATE_GENERAL,1000,Any() );
     }
 
-    const OUString aQuote  = m_xMetaData->getIdentifierQuoteString();
-    aNewName = ::dbtools::quoteName(aQuote,aName);
-    return aNewName;
+    // We need to refer to it by its "real" name, that is by schemaName.tableName.columnNameInTable
+    return impl_getColumnRealName_throw(column, false);
 }
 
 void SAL_CALL OSingleSelectQueryComposer::appendOrderByColumn( const Reference< XPropertySet >& column, sal_Bool ascending ) throw(SQLException, RuntimeException)
commit 69a061509b728055c0f30f36427e2efa63424cbd
Author: Lionel Elie Mamane <lionel at mamane.lu>
Date:   Thu Aug 1 13:45:31 2013 +0200

    fdo#64117 *always* set the filter name to the correct name
    
    the removed test made absolutely no sense:
    aliasName is a fully-qualified name, but columns is indexed by column name.
    That is, schemaName.tableName.columnName as opposed to only columnName.
    
    Change-Id: I9066b5183298e3e6ab63c367594f92bb3e00979d

diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
index f7f88fd..5dd8337 100644
--- a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
+++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
@@ -243,8 +243,7 @@ public class SQLQueryComposer
             for (int m = 0; m < _filterconditions[n].length; m++)
             {
                 final String aliasName = getComposedAliasFieldName(_filterconditions[n][m].Name);
-                if ( columns.hasByName(aliasName))
-                    _filterconditions[n][m].Name = aliasName;
+                _filterconditions[n][m].Name = aliasName;
             }
         }
         return _filterconditions;


More information about the Libreoffice-commits mailing list