Skip to content
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

Browser adds layers to projects with a leading space #43129

Closed
Jeroen-GroeneBij opened this issue May 7, 2021 · 12 comments · Fixed by #43436
Closed

Browser adds layers to projects with a leading space #43129

Jeroen-GroeneBij opened this issue May 7, 2021 · 12 comments · Fixed by #43436
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! QGIS Browser

Comments

@Jeroen-GroeneBij
Copy link

Using QGIS 3.16.4 on windows 10 I noticed DB manager not responding when working with a gpkg.

Use the following steps on the attached gem2015.gpkg as example
scenario 1
Save the gpgk in a folder
Use qgis browser panel to locate folder
drag gem2015.gpgk to the canvas
start db manager, go to virtual layers, click gem2015 (in project layer), open sql window
SELECT * FROM gem2015
No respons from db manager

scenario 2
close db manager
new qgis project
Use qgis browser panel to locate folder
left click click on gem2015.gpgk
drag vectorlayer gem2015 to canvas
start db manager, go to virtual layers, click gem2015 (in project layer), open sql window
SELECT * FROM gem2015
Everything is working fine.

The gpkg was created by saving a vectorlayer as gpgk. Same behaviour happend on a geojson layer saved as gpgk.

gem2015.zip

@Jeroen-GroeneBij Jeroen-GroeneBij added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label May 7, 2021
@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented May 7, 2021

Hi @Jeroen-GroeneBij, try with: SELECT * FROM " gem2015"
Does it works for you in the "scenario 1"?
If you look better at the layer name in the Layers panel for the "scenario 1", you will find that it incorrectly contains a leading space. So I think your issue is due to this incorrect behaviour.

@Jeroen-GroeneBij
Copy link
Author

Good find @agiudiceandrea. I did not put that leading space there. And now you mentioned it I see this all the time. Any gpkg I open gets this leading space in the layer name.

That is hard to spot. And since I mainly use gpkg with a single vector layer, the vector layer often has the same name as the gpkg (default behaviour when saving as gpkg), so I was unaware of this when running db manager. I just recently started using the virtual layer option in db manager, so never ran into this before.

Is it typical qgis behaviour to add a leading space. And why would that be so?

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented May 7, 2021

Is it typical qgis behaviour to add a leading space. And why would that be so?

No, I think it's an incorrect behaviour of the Browser. If you drag your GPKG file from Windows Explorer and drop it into the map or if you add the GPKG file using the Data Source Manager, then no leading space is added to the layer name.
So, it seems the issue is with the Browser, not the DB Manager.

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented May 8, 2021

The possibility to drag GPKG files from the Browser to the map was added to QGIS 3.16 with PR #38792. Maybe there is something not correctly addressed in such new feature.

@Jeroen-GroeneBij
Copy link
Author

Should I edit the title of this issue or open a new one? Because it is not actually a bug in db manager?

@gioman gioman changed the title DB Manager not working on gpkg but does work on layer within gpkg Browser adds layer to projects with a leading space May 9, 2021
@gioman gioman changed the title Browser adds layer to projects with a leading space Browser adds layers to projects with a leading space May 9, 2021
@elpaso
Copy link
Contributor

elpaso commented May 28, 2021

I cannot reproduce on Linux/master.

@elpaso
Copy link
Contributor

elpaso commented May 28, 2021

Can you check if the issue has been fixed in master?

@elpaso elpaso added the Feedback Waiting on the submitter for answers label May 28, 2021
@agiudiceandrea
Copy link
Contributor

@elpaso confirmed on latest master 5e15a2c on Windows 7 (MingW64 Windows 64bit Build).

@agiudiceandrea
Copy link
Contributor

Here is a screencast:

browser_gpkg_space.mp4

The following additional odd error is reported adding the GeoPackage:

CRITICAL    Invalid Layer : GDAL provider Cannot get GDAL raster band: (file: src/core/providers/gdal/qgsgdalprovider.cpp row: 2984function initBaseDataset:)
             Raster layer Provider is not valid (provider: gdal, URI: F:/QGIS/TEST/gem2015.gpkg (file: src/core/raster/qgsrasterlayer.cpp row: 661function setDataProvider:)

@elpaso
Copy link
Contributor

elpaso commented May 28, 2021

Errors are expected because we don't know if the GPKG contains any raster and we try to open with GDAL to see if there are any. This happens for all data sources that can contain rasters and vectors.

@elpaso elpaso removed the Feedback Waiting on the submitter for answers label May 28, 2021
@agiudiceandrea
Copy link
Contributor

Anyway, if you add a connection to the GeoPackage in the Browser panel, then you cannot add the GeoPackage from the GeoPackage tree node.

browser_gpkg_error.mp4
2021-05-28T16:57:55     CRITICAL    Invalid Layer : GDAL provider Cannot open GDAL dataset gpkg:/F:/QGIS/TEST/gem2015.gpkg:
              (file: src/core/providers/gdal/qgsgdalprovider.cpp row: 2890function initIfNeeded:)
             Raster layer Provider is not valid (provider: gdal, URI: gpkg:/F:/QGIS/TEST/gem2015.gpkg (file: src/core/raster/qgsrasterlayer.cpp row: 661function setDataProvider:)
2021-05-28T16:57:55     CRITICAL    Layer is not valid : The layer gpkg:/F:/QGIS/TEST/gem2015.gpkg is not a valid layer and can not be added to the map. Reason: 

@elpaso
Copy link
Contributor

elpaso commented May 28, 2021

Anyway, if you add a connection to the GeoPackage in the Browser panel, then you cannot add the GeoPackage from the GeoPackage tree node.

Which is a different bug but I'll look into that one too.

elpaso added a commit to elpaso/QGIS that referenced this issue May 28, 2021
nyalldawson pushed a commit that referenced this issue May 28, 2021
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! QGIS Browser
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants