Skip to content

In Refactor Fields algorithm, field for "Source Expression" are loaded from the wrong layer when "selected features only" option is checked #62019

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 tasks done
Scolopax opened this issue May 27, 2025 · 2 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Processing Relating to QGIS Processing framework or individual Processing algorithms

Comments

@Scolopax
Copy link

What is the bug or the crash?

When using Refactor Fields algorithm on a layer, and loading fields from a second layer, the fields displayed in "Source Expression" column are the one from the second layer. It only happens when "Selected features only" is checked.
The expected behavior would be to always display fields from the input layer in "Source Expression" column.

Steps to reproduce the issue

  1. create 2 vector layers and populate the first layer with some data
  2. launch Refactor Fields tool from Processing Toolbox
  3. select the first layer as Input layer and check the "Select features only" option
  4. Accept, or not, to reset the field mapping in the dialog which pops out (it doesn't change the result)
  5. select the second layer as template layer and click "Load field"
  6. Result : the fields displayed in the "Source Expression" column are the fields from the template layer and not the ones from the source layer.

Image

A possible workaround is to load fields from template layer with "Selected features" unchecked and then to check again the "Selected features" option without opting to reset the field mapping when proposed in the dedicated dialog.

This issue is not critical, as the above workaround can be used. However, it may be confusing for users unfamiliar with the refactoring tool.

Versions

QGIS version3.40.6-Bratislava
QGIS code revision5d7f6a3e26
 
Libraries
Qt version5.15.13
Python version3.12.10
GDAL version3.10.3
PROJ version9.6.0
EPSG Registry database versionv12.004 (2025-03-02)
GEOS version3.13.1-CAPI-1.19.2
SQLite version3.46.1
PDAL version2.8.3
PostgreSQL client versionunknown
SpatiaLite version5.1.0
QWT version6.3.0
QScintilla2 version2.14.1
OS versionWindows 11 Version 2009
 
Active Python plugins
db_manager0.1.20
grassprovider2.12.99
MetaSearch0.3.6
processing2.12.99

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

No response

@Scolopax Scolopax added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label May 27, 2025
@Scolopax Scolopax changed the title In Refactor Fields algorithm, field for "Source Expression" are loaded from the wrong layer when "selected features only" option is checkedis checked In Refactor Fields algorithm, field for "Source Expression" are loaded from the wrong layer when "selected features only" option is checked May 27, 2025
@DelazJ DelazJ added the Processing Relating to QGIS Processing framework or individual Processing algorithms label May 27, 2025
@roya0045
Copy link
Contributor

There's a slight bug where the field type in the Source Expression column are not always inferred depending if you are using the Selected Features option. But as far as what you describe, using the Load Fields will populate the entry using the field from the selected layer. I don't see a bug here. Maybe a gif would help but as far as I see it works as intended.

@Scolopax
Copy link
Author

Okay, let's not call this a bug. But I think it's at least a malfunction that worth reporting.
The simple fact that the behavior of load fields is different with or without selected features only is confusing for the user.
Furthermore, displaying the template layer fields in the Source Expression column makes no sense: in Source Expression, the user should always have access to the source layer fields, in the form of a drop-down list and in the expression builder.
For these reason, I think that fixing this malfunction would make Refactor fields algorithm more consistent and easy to use.

If it can help to illustrate the problem, here is a gif showing the expected behavior and then, with selected features only checked, the wrong fields displayed in Source Expression column.
Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Processing Relating to QGIS Processing framework or individual Processing algorithms
Projects
None yet
Development

No branches or pull requests

3 participants