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

it is not possible to save a project in the geopackage #36832

Closed
pigreco opened this issue May 29, 2020 · 33 comments · Fixed by #36980
Closed

it is not possible to save a project in the geopackage #36832

pigreco opened this issue May 29, 2020 · 33 comments · Fixed by #36980
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Project Windows Related to Windows operating system

Comments

@pigreco
Copy link
Sponsor Contributor

pigreco commented May 29, 2020

Starting from a new profile in QGIS MASTER, I can't save the project in a newly created geopackage.

how to reproduce the problem

  1. create a new geopackage from the browser panel
  2. import a vector into the geopackage
  3. load the vector into a new project
  4. save the project
  5. it is not possible to save it, URI error appears !!!

image

video demo master 3.13.55:
https://www.loom.com/share/1ff8fbc3e36a4a6888ce12ab35122ceb

OSGeo4W64

the problem is present in all versions 3.10, 3.12 and master

@pigreco pigreco added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label May 29, 2020
@gioman gioman added the Project label May 29, 2020
@agiudiceandrea
Copy link
Contributor

Hi @pigreco, I've tested the procedure using QGIS 3.10.6 and QGIS 3.12.3 (standalone installers) on Windows 10 and it seems the bug is only in QGIS 3.12.3, while QGIS 3.10.6 stores the project into the GeoPackage without problem.
Are you experiencing the bug also using QGIS 3.10?

@pigreco
Copy link
Sponsor Contributor Author

pigreco commented May 30, 2020

Are you experiencing the bug also using QGIS 3.10?

I did the same test (profile not new) in 3.10.6 and with new geopackage , it works!

But if I use an old geopackage, I can't save the project.

For 3.12 it is not important, it will be out soon, but in the master the problem persists.

Thanks for your interest.

--
video demo 3.10.6
https://www.loom.com/share/09822322731b4eb7bb8bbbfecfb987c4

--

EDIT

in 3.10.6, if I try to save a project in a geopackage created in another work session

image

@pigreco
Copy link
Sponsor Contributor Author

pigreco commented May 30, 2020

other comments:

  1. if I save the project in geopackage using 3.10.6, I see the project:

image

  1. but I don't see it in 3.13 (master)

image

  1. QGIS 3.12.3 I do not see the project
    image

geopackage

materiale_didattico.zip

@elpaso elpaso self-assigned this May 30, 2020
@gioman
Copy link
Contributor

gioman commented Jun 1, 2020

if I save the project in geopackage using 3.10.6, I see the project:

@pigreco this would be a different issue that needs a separate ticket. Also is similar to #33057

@gioman
Copy link
Contributor

gioman commented Jun 1, 2020

For 3.12 it is not important, it will be out soon, but in the master the problem persists.

@pigreco with QGIS master on Linux I'm able to save a project in your GPKG https://github.com/qgis/QGIS/files/4705440/materiale_didattico.zip At the end of the operation the project shows in the QGIS Browser and loads as expected.

@pigreco
Copy link
Sponsor Contributor Author

pigreco commented Jun 1, 2020

@pigreco this would be a different issue that needs a separate ticket. Also is similar to #33057

you are probably right, but I am noticing some problems and I am trying to make them present to help @elpaso

@elpaso
Copy link
Contributor

elpaso commented Jun 2, 2020

@pigreco is this problem only on windows?

@pigreco
Copy link
Sponsor Contributor Author

pigreco commented Jun 2, 2020

@pigreco is this problem only on windows?

i only use windows
can I ask friends to do the same test on linux.

I update you

@elpaso
Copy link
Contributor

elpaso commented Jun 2, 2020

It's working fine on Linux, so let's assume it's windows-only for now.

@elpaso elpaso added the Windows Related to Windows operating system label Jun 2, 2020
@albertograva
Copy link

I've tested in ubuntu 18.04 with 3.12.3-București and I can confirm that it works.

@gioman
Copy link
Contributor

gioman commented Jun 3, 2020

@pigreco and it works fine also on master on Windows here...

@gioman gioman added the Feedback Waiting on the submitter for answers label Jun 3, 2020
@gioman
Copy link
Contributor

gioman commented Jun 3, 2020

@pigreco and on 3.12/Windows too...

@pigreco
Copy link
Sponsor Contributor Author

pigreco commented Jun 3, 2020

@pigreco and on 3.12/Windows too...

I can't, maybe it's just my problem!

@gioman
Copy link
Contributor

gioman commented Jun 3, 2020

I can't, maybe it's just my problem!

@pigreco I would suggest having a completely clean Virtual Machine (you can download the Windows ISO from the MS site) and use to double check if what you are seeing on your work machine confirms or not.

@pigreco
Copy link
Sponsor Contributor Author

pigreco commented Jun 3, 2020

@gioman

your suggestion is good,
but before venturing into a virtual machine I would wait for another test on windows from a third person.
thanks

@gioman
Copy link
Contributor

gioman commented Jun 3, 2020

but before venturing into a virtual machine

@pigreco you do much more difficult things with QGIS and databases... ;)

@pigreco
Copy link
Sponsor Contributor Author

pigreco commented Jun 3, 2020

perhaps I abandon the idea of saving the project file in the geopackage. :-(

image

@agiudiceandrea
Copy link
Contributor

Hi @pigreco, @elpaso, @gioman, as previously already reported, I can confirm the first described bug, following the described procedure with alaska.shp as layer, occurring on Windows 10 64 bit using QGIS 3.12.3 (standalone installer) with a new clean profile:
Video_3_12_3

It also occurs using QGIS 3.13.0-Master code revision 81abbbb May 29th 2020 (OSGeo4W installer):
Video_3_13

It doesn't occur using QGIS 3.10.6 (standalone installer):
Video_3_10_6

@gioman
Copy link
Contributor

gioman commented Jun 4, 2020

the described procedure

Then maybe the described procedure is not clear. Can you tell what are the steps to follow?

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Jun 4, 2020

I've just followed these #36832 (comment) very steps:

  1. create a new geopackage ["test.gpkg" in "C:\TEST\", with a no geometry table named "test"] from the browser panel [the Geopackage is created, a new connection is automatically created ad appears under the GeoPackage node in the Browser panel, the table "test" is automatically added as layer in the current project "Untitled Project"]
  2. import a vector into the geopackage [in the Browser panel, drag a vector layer (in this case, "C:\TEST\alaska.shp" from https://qgis.org/downloads/data/qgis_sample_data.zip) and drop it into the GeoPackage "test.gpkg" under the GeoPackage node]
  3. load the vector into the project [drag and drop the layer "alaska" from the "test.gpkg" geopackage under the GeoPackage node to the Layers panel, or simply double click the layer "alaska" in "test.gpkg"]
  4. save the project [using Project->Save To->GeoPackage..., select the already connect "test.gpkg" GeoPackage and enter a name for the project to save, e.g. "test_project"]

then the project is not saved and an error window is displayed with the following text:

Unable to save project to storage geopackage:C:%5CTEST%5Ctest.gpkg?projectName=test_project

Unable to insert or update project (project=geopackage:C:%5CTEST%5Ctest.gpkg?projectName=test_project) in the destination table on the database: Invalid URI for GeoPackage OGR provider: C:\TEST\test.gpkg

@agiudiceandrea
Copy link
Contributor

I suppose this regression could be due to a change in QgsGeoPackageProjectStorage between 3.10 and 3.12.
Maybe 3dcbde9 (#33265)?

@gioman
Copy link
Contributor

gioman commented Jun 4, 2020

@agiudiceandrea seen the error. What it makes the difference if is the connection to the GPKG is added manually or automatically as described in step 1. If the connection created in step1 is removed, then re-created manually then it works as expected.

@elpaso
Copy link
Contributor

elpaso commented Jun 4, 2020

@agiudiceandrea pretty unlikely because that was exactly what I was testing (besides the shares paths). I'm more thinking at a side effect of other issues that I'm fixing now #36972

@gioman can you please clarify? I couldn't reproduce on windows master with the instructions above (I'm not using a network share either).
Do you have a clear path to reproduce this on windows?

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Jun 4, 2020

If the connection created in step1 is removed, then re-created manually then it works as expected.

I can confirm.
It also doesn't occur if the new GeoPackage is created using "New GeoPackage Layer..." (because in this case the connection needs to be made manually).

I'm more thinking at a side effect of other issues that I'm fixing now #36972

I think I've spotted your issue during the test in my previous screencast (here an excerpt) with 3.13-master (but not with 3.12.3, nor 3.10.6):
Video_2020-06-04_113048
image

Anyway, I can reproduce the original issue without using drag and drop and without importing any layer in the GeoPackage.

Here a minimum set of steps to reproduce the bug:

  1. create a new geopackage ["test.gpkg" in "C:\TEST", with a no geometry table named "test"] from the browser panel [the Geopackage is created, a new connection is automatically created ad appears under the GeoPackage node in the Browser panel, the table "test" is automatically added as layer in the current project "Untitled Project"]
  2. save the project [using Project->Save To->GeoPackage..., select the already connect "test.gpkg" GeoPackage and enter a name for the project to save, e.g. "test_project"]

then the project is not saved and an error window is displayed with the following text:

Unable to save project to storage geopackage:C:%5CTEST%5Ctest.gpkg?projectName=test_project

Unable to insert or update project (project=geopackage:C:%5CTEST%5Ctest.gpkg?projectName=test_project) in the destination table on the database: Invalid URI for GeoPackage OGR provider: C:\TEST\test.gpkg

image
In this error message there is no mention of "gpkg:/".

@gioman
Copy link
Contributor

gioman commented Jun 4, 2020

Do you have a clear path to reproduce this on windows?

@elpaso is as @agiudiceandrea said, create a new database from the browser > it will auto-add a connection. At this point saving a project using this connection will fail. If you remove that connection and recreate it manually it will work.

@elpaso elpaso removed the Feedback Waiting on the submitter for answers label Jun 4, 2020
@elpaso
Copy link
Contributor

elpaso commented Jun 4, 2020

@agiudiceandrea and you were right ... it's a side effect of the network patch. I'm able to reproduce it now.

@agiudiceandrea
Copy link
Contributor

agiudiceandrea commented Jun 4, 2020

Maybe changing

errCause = _executeSql( projectUri.database, sql );

to
errCause = _executeSql( uri, sql );

like is in

errCause = _executeSql( uri, QStringLiteral( "CREATE TABLE qgis_projects(name TEXT PRIMARY KEY, metadata BLOB, content BLOB)" ) );

could fix the issue?

@elpaso
Copy link
Contributor

elpaso commented Jun 4, 2020

@agiudiceandrea nope, the root of the issue is in QgsGeoPackageItemGuiProvider::createDatabase(), I have a patch but testing on windows takes ages on my dev machine ... slow, tedious and boring ...

Have a look to the settings file and you will see that depending on how you store the connections it is stored ad C:/.... or C:\.... and that makes all the difference in the URI encoding.

@elpaso
Copy link
Contributor

elpaso commented Jun 4, 2020

@agiudiceandrea anyway I'll check if that difference in _executeSql make sense.

elpaso added a commit to elpaso/QGIS that referenced this issue Jun 4, 2020
... in a particular sequence of connection creation,
fixes qgis#36832
@elpaso
Copy link
Contributor

elpaso commented Jun 4, 2020

I'd really like some tests from the windows users on this patch:
#36980
What to test:

  • create gpkgs in different ways and add connections to existing gpkgs from various sources (C:, network shares starting with // etc.)
  • create a project and store it into the gpkgs
  • check the operations (delete, update etc.)

The problems are due to the different ways windows uses to store paths, I put code in place to normalize it but there are no automated tests.

@pigreco
Copy link
Sponsor Contributor Author

pigreco commented Jun 4, 2020

I'd really like some tests from the windows users on this patch:
#36980

how do i test ??
what should i download ??

@elpaso
Copy link
Contributor

elpaso commented Jun 5, 2020

@pigreco wait for the nightly build please, MXE builds are unfortunately no longer available.

@pigreco
Copy link
Sponsor Contributor Author

pigreco commented Jun 7, 2020

Good morning,
I did a test using the master
IT WORKS!!!

here is a video.
https://www.loom.com/share/9c9beb015a6849b5964256250fd7a8e2
thank you very much

nyalldawson pushed a commit to nyalldawson/QGIS that referenced this issue Jul 9, 2020
... in a particular sequence of connection creation,
fixes qgis#36832

(cherry picked from commit 2d3c36f)
nyalldawson pushed a commit that referenced this issue Jul 21, 2020
... in a particular sequence of connection creation,
fixes #36832

(cherry picked from commit 2d3c36f)
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! Project Windows Related to Windows operating system
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants