File tree 2 files changed +19
-0
lines changed
python/plugins/processing
2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,12 @@ def linkTestfile(f, t):
92
92
name = vector .ogrLayerName (tmpdir + '|layername=f2|layerid=0' )
93
93
self .assertEqual (name , 'f2' ) # layername takes precedence
94
94
95
+ name = vector .ogrLayerName ('dbname=\' /tmp/x.sqlite\' table="t" (geometry) sql=' )
96
+ self .assertEqual (name , 't' )
97
+
98
+ name = vector .ogrLayerName ('dbname=\' /tmp/x.sqlite\' table="s.t" (geometry) sql=' )
99
+ self .assertEqual (name , 's.t' )
100
+
95
101
def testFeatures (self ):
96
102
ProcessingConfig .initialize ()
97
103
Original file line number Diff line number Diff line change @@ -533,6 +533,19 @@ def ogrConnectionString(uri):
533
533
534
534
535
535
def ogrLayerName (uri ):
536
+ if 'host' in uri :
537
+ regex = re .compile ('table="(.+?)\.(.+?)"' )
538
+ r = regex .search (uri )
539
+ return '"' + r .groups ()[0 ] + '.' + r .groups ()[1 ] + '"'
540
+ elif 'dbname' in uri :
541
+ regex = re .compile ('table="(.+?)"' )
542
+ r = regex .search (uri )
543
+ return r .groups ()[0 ]
544
+ elif 'layername' in uri :
545
+ regex = re .compile ('(layername=)([^|]*)' )
546
+ r = regex .search (uri )
547
+ return r .groups ()[1 ]
548
+
536
549
fields = uri .split ('|' )
537
550
ogruri = fields [0 ]
538
551
fields = fields [1 :]
You can’t perform that action at this time.
0 commit comments