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

Fix extraction of ogr LayerName from geodatabase URIs using layerid #3605

Closed

Conversation

strk
Copy link
Contributor

@strk strk commented Oct 14, 2016

Closes #15698

\cc @volaya, @rouault

@strk strk added For Review Requires Tests! Waiting on the submitter to add unit tests before eligible for merging labels Oct 14, 2016
@strk strk self-assigned this Oct 14, 2016
@strk
Copy link
Contributor Author

strk commented Oct 14, 2016

@volaya is there a testing framework in use for processing plugin ?

@@ -521,6 +523,21 @@ def ogrLayerName(uri):
regex = re.compile('(layername=)(.*)')
r = regex.search(uri)
return r.groups()[1]
elif '.gdb' in uri:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why triggering on .gdb only and not layerid= ? Could happen with other multi-layer formats.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole thing looks fragile at the first glace - hosts.shp? dbnames.csv? layernames.dbf?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is to handle the case in which there's no "|layerid" nor "|layername".
Can that case be generalized ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually if you changed your "elif '.gdb' in uri:" as a simple else (and remove the existing else clause), that should be more general

@jef-n
Copy link
Member

jef-n commented Oct 14, 2016

@strk
Copy link
Contributor Author

strk commented Oct 14, 2016

@volaya was python/plugins/processing/tests/VectorTest.py a good choice for a unit test for python/plugins/processing/tools/vector.py ?

@strk strk removed the Requires Tests! Waiting on the submitter to add unit tests before eligible for merging label Oct 14, 2016
@strk strk force-pushed the release-2_16-fix-geodatabase-import branch from 975c32e to 980b569 Compare October 14, 2016 16:08
@strk
Copy link
Contributor Author

strk commented Oct 14, 2016

Generalized, equipped with tests and squash-rebased

@nyalldawson
Copy link
Collaborator

@strk master has https://github.com/qgis/QGIS/blob/master/python/plugins/processing/tests/ToolsTest.py which covers some of the vector stuff - you could safely backport just this file and add your tests there. All the existing tests are just protections while refactoring.

@strk
Copy link
Contributor Author

strk commented Oct 14, 2016

Thanks @nyalldawson, backported the test to 2.16 branch (and noticed there was an API break between 2.16 and 2.18, expected?)

@strk
Copy link
Contributor Author

strk commented Oct 14, 2016

Now I have to fix the expectances of my test:
https://travis-ci.org/qgis/QGIS/jobs/167687357#L1085

@rouault is lack of "layer*" specification completely undefined as for which file would be considered "layer0" for a directory dataset ?

@rouault
Copy link
Contributor

rouault commented Oct 14, 2016

@rouault is lack of "layer*" specification completely undefined as for which file would be considered "layer0" for a directory dataset ?

Yes, more or less. For a given dataset on a given machine, the order will presumably remain constant if the OS readdir() or equivalent call used returns file names in the same order.

@nyalldawson
Copy link
Collaborator

@strk Hmmm... What was the api break?

@strk
Copy link
Contributor Author

strk commented Oct 14, 2016

@nyalldawson features() taking only 1 argument, while in master_2 the two final tests are passing 2 arguments (I've omitted those two in the backport)

Adds supports for "layerid" when present.
Drop special handling for "table=" portions found in URI,
making the code more generic.

Includes testcase.

Fixes qgis#15698 - import geodatabase to postgis via processing
@strk
Copy link
Contributor Author

strk commented Oct 14, 2016

btw Nyall, you're an year ahead in the copyright notice :)

@strk strk force-pushed the release-2_16-fix-geodatabase-import branch from 4d3ce1b to eca4199 Compare October 14, 2016 21:14
@nyalldawson
Copy link
Collaborator

@strk it's not a break though, because the new argument has a default value. So old code will still work.

@strk
Copy link
Contributor Author

strk commented Oct 15, 2016

Pushed as squashed commit 1b1b238

Thanks for confirming, @nyalldawson

@strk strk closed this Oct 15, 2016
@luipir
Copy link
Contributor

luipir commented Sep 7, 2017

@strk test introduced to fix this issue started to fail due different factors:

  1. it fail in case data and tmp are in different filesystem (due to hard link nature).
    A proposed patch here: fix processing test in case data and tmp are in different filesystem #5151

  2. in [bugfix] backport from 3.0 Fix unit of sizes when reading a SLD file (fixes #8978) #5144 you can find reports that fail in Travis and in different test configurations

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants