wizards/com/sun/star/wizards/db/SQLQueryComposer.java |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

New commits:
commit a2888a8f5a2fd5a01a709ce445fe479059c16d59
Author:     Alexandre Sena Coelho <alexandre...@yahoo.com>
AuthorDate: Mon Dec 30 08:17:17 2024 -0300
Commit:     Hossein <hoss...@libreoffice.org>
CommitDate: Tue Feb 18 16:06:22 2025 +0100

    tdf#161144 Fix ambiguous sorting in Query Wizard
    
    Fix ambiguous sorting in Query Wizard by including table names in
    ORDER BY clause
    
    Change-Id: Ie178c366f501156f72ff0bd441a75be98dc15220
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/179564
    Tested-by: Jenkins
    Reviewed-by: Hossein   <hoss...@libreoffice.org>

diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java 
b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
index ca8b968baeec..a7ea7f01ef2b 100644
--- a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
+++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
@@ -161,6 +161,7 @@ public class SQLQueryComposer
     private void appendSortingCriterion(int _SortIndex, boolean 
_baddAliasFieldNames) throws SQLException
     {
         String sSortValue = CurDBMetaData.getSortFieldNames()[_SortIndex][0];
+        String currentOrder = m_queryComposer.getOrder();
         XPropertySet xColumn = 
CurDBMetaData.getColumnObjectByFieldName(sSortValue, _baddAliasFieldNames);
 
         String sSort = "ASC";
@@ -168,8 +169,9 @@ public class SQLQueryComposer
         {
             sSort = CurDBMetaData.getSortFieldNames()[_SortIndex][1];
         }
-        boolean bascend = !(sSort.equals("DESC"));
-        m_queryComposer.appendOrderByColumn(xColumn, bascend);
+        String tablePrefixedFieldName = 
getComposedAliasDisplayName(sSortValue);
+        currentOrder += (!currentOrder.isEmpty() ? ", " : "") + 
tablePrefixedFieldName + " " + sSort;
+        m_queryComposer.setOrder(currentOrder);
     }
 
     private void appendSortingcriteria(boolean _baddAliasFieldNames) throws 
SQLException

Reply via email to