Bug 421126 - Securities Dialog "Market" field not populated with existing data on edit
Summary: Securities Dialog "Market" field not populated with existing data on edit
Status: RESOLVED FIXED
Alias: None
Product: kmymoney
Classification: Applications
Component: general (show other bugs)
Version: 5.0.5
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: KMyMoney Devel Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-06 23:07 UTC by JAH
Modified: 2020-06-05 04:08 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 5.1.0


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description JAH 2020-05-06 23:07:19 UTC
SUMMARY
When editing / updating a Security, the Market field (which I use to store Country & Sector codes) is not populated with any existing data although changes are stored. Only a small drop-down list of possible markets is shown 
although the field seems able to store any string value. 

STEPS TO REPRODUCE
1. Open a Security record using the Edit button
2. 
3. 

OBSERVED RESULT
The "Market" field is blank

EXPECTED RESULT
The "Market" field should be populated with any data currently stored iin the field so it can be edited

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: Opensuse Leap 15.1
(available in About System)
KDE Plasma Version: 5.12.8
KDE Frameworks Version: 5.55.0
Qt Version: 5.9.7

ADDITIONAL INFORMATION
Comment 1 Jack 2020-05-06 23:39:49 UTC
Are you certain that there really is existing data in that field?  I just checked, and some securities had that blank, but others had a value shown.  I don't believe it is automatically filled in, and I know I don't always enter a value when creating new securities.  Perhaps the next time you edit security and do not see a value, you can make a copy of your data file (before using File/Save) uncompress it if necessary (.kmy file is just .xml.gz) and then grep for the security line in the file.  (Hint, grep for "SECURITY.*name of sec" or you will likely get far to many hits.)  If this seems to complex, just say so, and I can give simpler instructions.
Comment 2 JAH 2020-05-08 10:00:20 UTC
Thanks for the tip re: .kmy files being compressed XML - I didn't know that.

Yes I'm sure the field has been populated in my database (even though it has no default value as you point out). 

To test for yourself:

1. Populate the field with one of the Market codes from the drop down box. This code will persist through successive edits.

2. Populate the field with anything else. It will be saved correctly first time but it will NOT persist through an edit of that field.

Since existing market codes DO survive persistent editing, I wondered if this behaviour is by design as a way of validating entries against the drop-down list but that would seem to be unnecessarily proscriptive - precluding the entry of any market codes now or in the future that are not already in the list. Furthermore validation does not explain how ad-hoc entries survive being stored in the first place.

It seems that when selecting the TradingMarket field in the Security > Edit dialog, the first entry in the drop-down list is blank and if left unchanged, any existing data is over-written with NULL when the record is saved. I believe more normal behaviour would be for the first item in the drop down list to be populated with any existing data in the record thus ensuring that, without further action, the existing entry/data is preserved.
Comment 3 Jack 2020-05-08 14:17:42 UTC
I agree something is not right here, and if you can actually enter a value, it should be saved.  If you are not meant to enter a new value, you shouldn't even be able to type it (combo-box v drop-down).  I suspect the value is not actually even being saved the first time, it just seems to be accepted and remains in the field until you switch to another view.  This will likely require some input from one of the developers.
Comment 4 Thomas Baumgart 2020-05-08 16:19:07 UTC
Git commit 06c11e35e04eef6f3be86698e2c11c3da97b2925 by Thomas Baumgart.
Committed on 08/05/2020 at 16:18.
Pushed by tbaumgart into branch '5.0'.

Remember user defined trading markets
FIXED-IN: 5.0.9

M  +11   -1    kmymoney/wizards/newinvestmentwizard/kinvestmentdetailswizardpage.cpp

https://commits.kde.org/kmymoney/06c11e35e04eef6f3be86698e2c11c3da97b2925
Comment 5 JAH 2020-05-08 23:35:59 UTC
Thank you for reviewing  this issue and providing a fix.