Bug 133823 - Firebird: Alias in a query will give "CASE" as column name in a form, if a field with same name existed
Summary: Firebird: Alias in a query will give "CASE" as column name in a form, if a fi...
Status: RESOLVED DUPLICATE of bug 132924
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Base (show other bugs)
Version:
(earliest affected)
6.4.4.2 release
Hardware: x86-64 (AMD64) All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-09 13:50 UTC by Robert Großkopf
Modified: 2022-03-24 21:51 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Test the two forms. Press the button: different column names will be shown with the same SQL-code. (21.52 KB, application/vnd.oasis.opendocument.database)
2020-06-09 13:50 UTC, Robert Großkopf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Großkopf 2020-06-09 13:50:59 UTC
Created attachment 161809 [details]
Test the two forms. Press the button: different column names will be shown with the same SQL-code.

Open the attached database.
Open the form "form_query" and press the button.
Column names of the query the form depends of are shown.
But there is one column "CASE", which isn't part of the query.

Now close the form and open the form with the same SQL code. The code is direcly connected to the form, not through a query.
Press the button and you could see the column names. 
This column names are the same as shown in the query.

This is the query:
SELECT "ID", "forename", "sex" "s_short", CASE WHEN "sex" = 'm' THEN 'Mister' ELSE 'Miss' END "sex" FROM "table1"

The bug only appears if there is a field, which is defined in the table with the same name as another field gets for alias. Table contains "sex", which is changed by alias to "s_short" and then another field appears with alias "sex".
The bug appears with queries, but not with SQL-code, which is set directly in the form.

Might be related to
https://bugs.documentfoundation.org/show_bug.cgi?id=132924
Comment 1 Alex Thurgood 2020-06-24 06:38:22 UTC
Confirming with

Version : 6.4.4.2
Build ID : 3d775be2011f3886db32dfd395a6a6d1ca2630ff
Threads CPU : 8; OS : Mac OS X 10.15.5; UI Render : par défaut; VCL: osx; 
Locale : fr-FR (fr_FR.UTF-8); Langue IHM : fr-FR
Calc: threaded
Comment 2 Alex Thurgood 2020-06-24 06:50:21 UTC
Seems like the parser can't handle the CASE WHEN statement and just segments after the first space taking CASE as the column name. Could be that this is indeed a DUP of bug 1329294.
Comment 3 debewerking 2020-10-07 09:29:06 UTC
Comment on attachment 161809 [details]
Test the two forms. Press the button: different column names will be shown with the same SQL-code.

I experienced identical behaviour and like to strengthen Alex Thurgoods vision. In a base query with SQL ( excerpt: CURRENT_DATE AS "datum", 'F' || "IDgbwriter" || "volgnr" AS "filenaam", ( "tblgb"."gb" - TRUNC( "tblgb"."gb", - 2 ) ) * 1000 + "volgnr" AS "factuurnummer") the aliases are correctly displayed in the query GUI, however the same SQL string in a basic macro evaluated with the PrepareStatement( stringSQL ) and executeQuery()shows that the given alias names are ignored, and reassigned as "CURRENT_DATE" , ADD3 , CONCAT and the like.
Comment 4 Andreas Heinisch 2022-03-24 21:51:25 UTC
Should be fixed with Bug 132924.

*** This bug has been marked as a duplicate of bug 132924 ***