Bug report #14157
Existing virtual layers replaced when using "add virtual layer"
|Affected QGIS version:||master||Regression?:||No|
|Operating System:||Easy fix?:||No|
|Pull Request or Patch supplied:||No||Resolution:||fixed/implemented|
|Crashes QGIS or corrupts data:||No||Copied to github as #:||22159|
The new "Add virtual layer" dialog sometimes replaces an existing virtual layer, even if the new layer has a different name to the layer which gets replaced.
(my) steps to reproduce:
1. add a virtual layer, "select * from address where road_name='PATTERSON'", with layer name 'patterson'. Layer is added correctly.
2. press "add virtual layer" again.
3. Change the name to "bentleigh", sql to "select * from patterson where locality_name='BENTLEIGH'". Press OK. Layer replaces existing 'patterson' layer.
I'd have expected that since the layer has a different name, it wouldn't have replaced the existing layer (regardless of the state of the "replace" checkbox).
#1 Updated by Hugo Mercier over 5 years ago
Thanks for your feedback.
I am thinking, in terms of UI it could be better to forget this "replace" checkbox and use the name of the layer as you mentioned:
- if the name is the same, ask the user if he is sure to replace it
- if the name is different, create a new one
What do you think ?
#2 Updated by Nyall Dawson over 5 years ago
Sounds great! A possible further improvement could be:
1. Change the layer name text box to a combo box, showing all current virtual layers but also allowing manual entry.
2. If an existing virtual layer is selected from the combo, the sql definition is updated to match that layer.
3. If you click ok and the current value of the layer name combo matches an existing virtual layer, you are prompted with the warning that the existing layer will be over written.
What do you think?