Bug 432359

Summary: In a table, it is not possible to specify a lookup query from the same table (alias doesn't matter)
Product: [Applications] KEXI Reporter: Antonio <antonio.angelo>
Component: TablesAssignee: Kexi Bugs <kexi-bugs>
Status: REPORTED ---    
Severity: grave CC: adam, inksi, staniek
Priority: NOR    
Version: 3.2.0   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Microsoft Windows   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Antonio 2021-01-31 17:06:52 UTC
SUMMARY

A field in a table cannot be populated by a lookup query from the same table. 

STEPS TO REPRODUCE

1. Create new blank database my_db
2. Create new table an_actors as: 
    id_actor integer, PK, autoincrement
    tx_actor text
    tx_gender text
    id_father integer
    id_mother integer
3. Populate an_actors with 2 records: 
    tx_actor,   tx_gender
    '(unknown)' '(unknown)'
    'White'     'M'
    'Black'     'F'
4. Create new query qry_fathers from an_actors:
    id_actor AS id_father
    tx_actor AS tx_father
    WHERE tx_gender <> 'F'
5. Create new query qry_mothers from an_actors:
    id_actor AS id_mother
    tx_actor AS tx_mother
    WHERE tx_gender <> 'M'
6. Table and queries were tested OK.

7. Open table an_actors in design mode, opening field id_father Lookup column: 
    Record source: qry_fathers
    Bound column: id_actor
    Visible column: tx_actor

8. Switch from Lookup column to Properties, then Save table (without switching, Kexi crashes).

9. Open table an_actor in data mode, specifying id_father '(unknown)' for each tx_actor ('White', 'Black'), the save record.

10. Open again table an_actor but all records have tx_actor='(unknown)'.

OBSERVED RESULT
tx_actor is filled with the tx_value returned by the lookup query, and aliases seems to be useless.
It seems not possible to use a query from the same table, as a lookup table.

EXPECTED RESULT
tx_actor should remain untouched, while id_father and id_mother should return the tx_value selected in the lookup query.
If I add a field to be populated from a lookup query from a different table, the problem does not arise.

SOFTWARE/OS VERSIONS
Windows: 10 Home

ADDITIONAL INFORMATION
This problem is highly reproducible.
Comment 1 Jarosław Staniek 2021-01-31 17:42:01 UTC
Thank you for the report.