Bug 143400 - Query with most functions could not be created in GUI
Summary: Query with most functions could not be created in GUI
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
7.2.0.1 rc
Hardware: All All
: highest major
Assignee: Julien Nabet
URL:
Whiteboard: target:7.3.0 target:7.2.0.2
Keywords: bibisectRequest, regression
Depends on:
Blocks:
 
Reported: 2021-07-16 06:47 UTC by Robert Großkopf
Modified: 2021-07-17 09:34 UTC (History)
3 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Großkopf 2021-07-16 06:47:09 UTC
Take the following attachment:
https://bugs.documentfoundation.org/attachment.cgi?id=173603

Go to Queries → Create Query in Design view.
Choose "Table1".
Choose field "Date" from table.
Run query - works.
Choose function "Maximum".
Run Query.
Query fails (and most of the editor disappears here).
The created code is completely nonsense: Column not found: Maximu in statement [SELECT MAX( "Maximu" ) FROM "Table1"]
It has to be
SELECT MAX("Date") FROM "Table1"

This bug first appears in LO 7.2.0.1, has never appeared in any version 7.1 or before.
Comment 1 Robert Großkopf 2021-07-16 06:51:49 UTC
It is the same behavior with other functions like "Minimum", "Count" and - if field "ID" is choosen - SUM …

Seems no function except GROUP will work any more. Unusable!
Comment 2 Alex Thurgood 2021-07-16 08:19:59 UTC
Confirming with 

Version: 7.2.0.1 / LibreOffice Community
Build ID: 32efc3b7f3a71cfa6a7fa3f6c208333df48656cc
CPU threads: 8; OS: Mac OS X 10.16; UI render: default; VCL: osx
Locale: fr-FR (fr_FR.UTF-8); UI: en-US
Calc: threaded
Comment 3 Julien Nabet 2021-07-16 18:42:07 UTC
On pc Debian x86-64 with master sources updated today, I could reproduce this.

Regression from https://cgit.freedesktop.org/libreoffice/core/commit/?id=04aafba860f613c20e7078d038cc83eb02de0b54
loplugin:stringadd simplify some *StringBuffer operations
pulled from a larger patch which I created with a more permissive
variant of this plugin

Specifically here:
-------------- dbaccess/source/ui/querydesign/QueryDesignView.cxx --------------
index 22408bbc58aa..63c5d07998ec 100644
@@ -658,11 +658,10 @@ namespace
                     if  ( field->isAggregateFunction() )
                     {
                         OSL_ENSURE(!field->GetFunction().isEmpty(),"Function name must not be empty! ;-(");
-                        OUStringBuffer aTmpStr2( field->GetFunction());
-                        aTmpStr2.append("(");
-                        aTmpStr2.append(aTmpStr.makeStringAndClear());
-                        aTmpStr2.append(")");
-                        aTmpStr = aTmpStr2;
+                        aTmpStr = field->GetFunction() +
+                            "(" +
+                            aTmpStr +
+                            ")";
                     }
 
                     if (!rFieldAlias.isEmpty()                         &&
Comment 4 Julien Nabet 2021-07-16 18:56:41 UTC
I gave a try with:
https://gerrit.libreoffice.org/c/core/+/119088
Comment 5 Commit Notification 2021-07-17 07:05:21 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/4a096b9c787fa2079ef1c8f00fed91d432d46fae

tdf#143400: fix query with most functions could not be created in GUI

It will be available in 7.3.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.
Comment 6 Julien Nabet 2021-07-17 07:24:30 UTC
Backport for 7.2 waiting for review here:
https://gerrit.libreoffice.org/c/core/+/119039

Thank you Robert for having spotted this one!
Comment 7 Commit Notification 2021-07-17 09:34:31 UTC
Julien Nabet committed a patch related to this issue.
It has been pushed to "libreoffice-7-2":

https://git.libreoffice.org/core/commit/0c8d209683e04f22e924e125f778e00836c0b132

tdf#143400: fix query with most functions could not be created in GUI

It will be available in 7.2.0.2.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.