Bug report #9404

Browser can only connect to one spatialite file of several files sharing the same name

Added by Olivier Dalang over 10 years ago. Updated about 5 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Data Provider/SpatiaLite
Affected QGIS version:2.0.1 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:no timely feedback
Crashes QGIS or corrupts data:No Copied to github as #:18001

Description

Hi !

If you have two spatialite files with the same name but in different folders, you can only connect to one using the browser "new connection" function.
When you try to add the other one, the first connection remains unchanged. You need to remove the first one in order to actually connect to the other one.

The Browser should enable adding each spatialite file once, even if they have the same name.

Thanks !!

Olivier

History

#1 Updated by Etienne Tourigny over 10 years ago

It seems to me this is by design and would be hard to change. sqlite connections are stored in QGIS2.conf like this, there is now way to store 2 items with same name:

[SpatiaLite]
connections\\selected=gis.sqlite
connections\\gis.sqlite\\sqlitepath=/data/research/data/gis/tmp/gis.sqlite

How would you show 2 entries with the same name in the browser? You would need to add the path to the name which is not convenient.

Probably easier to just rename your second sqlite file before adding it to the browser.

For now it should be wise to show an error saying that you cannot add 2 connections with the same name.

Ideally, one should be able to rename sqlite items to do what you want.

#2 Updated by Etienne Tourigny over 10 years ago

  • % Done changed from 0 to 50

Added warning in commit fbdf34c2b26e90f7c6e077eb54be53cae03d100f - and previous connection is preserved.

Setting this task as 50% Done because real fix would be to allow several files with same file name, but different paths and also different names in the browser.

Perhaps adding and incremental counter to the name would do the trick?

#3 Updated by Olivier Dalang over 10 years ago

Hi ! Thanks for quick reaction !!

Actually, I sometimes need specifically to have two spatialite databases with the same name.
This allows to have two variants of a project's database and simply duplicate the QGIS project to be able to display both.

About how to display them in the browser, I'd say displaying them with the same name and the file path on mouseover would be good enough. It means the ID would have to be the filepath, though...

#4 Updated by Etienne Tourigny over 10 years ago

Changing the way connection are stored in settings requires some thinking, in order to not break things.

Perhaps any new connections would use full path, and old connections would remain as is.

Would there be any portability issues with this? Let's say you have a project that was created in linux, if opened in windows the stored sqlite connection would not be found.

Adding other devs which contributed to this code, to get their feedback.

#5 Updated by Etienne Tourigny over 10 years ago

If you use the full file path as key, this is what gets stored in the settings, and this does NOT work.

connections\\data\
esearch\\data\\gis\\tmp\\gis.sqlite\\sqlitepath=/data/research/data/gis/tmp/gis.sqlite

Simple (but not very convenient) solution would be to add a counter to key name (e.g. gis.sqlite_2).

#6 Updated by Jürgen Fischer almost 10 years ago

  • Category changed from Browser to Data Provider/SpatiaLite

#7 Updated by Giovanni Manghi almost 7 years ago

  • Regression? set to No
  • Easy fix? set to No

#8 Updated by Giovanni Manghi about 6 years ago

  • Status changed from Open to Feedback

Please test with a recent QGIS release (2.18 or 3), if the issue/request is still valid change the affected version accordingly, if is fixed/implemented then close the ticket. Thanks!

#9 Updated by Jürgen Fischer about 5 years ago

  • Resolution set to no timely feedback
  • Status changed from Feedback to Closed

Bulk closing 82 tickets in feedback state for more than 90 days affecting an old version. Feel free to reopen if it still applies to a current version and you have more information that clarify the issue.

Also available in: Atom PDF