Skip to content

Commit 99876cc

Browse files
committedOct 2, 2012
db_manager: get fields' size from formatted type string (fix #6402)
1 parent c74090d commit 99876cc

File tree

1 file changed

+8
-10
lines changed
  • python/plugins/db_manager/db_plugins/postgis

1 file changed

+8
-10
lines changed
 

‎python/plugins/db_manager/db_plugins/postgis/plugin.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -302,16 +302,14 @@ def __init__(self, row, table):
302302
self.num, self.name, self.dataType, self.charMaxLen, self.modifier, self.notNull, self.hasDefault, self.default, typeStr = row
303303
self.primaryKey = False
304304

305-
# convert the modifier to string (e.g. "precision,scale")
306-
if self.modifier != None and self.modifier != -1:
307-
trimmedTypeStr = QString(typeStr).trimmed()
308-
if trimmedTypeStr.startsWith(self.dataType):
309-
regex = QRegExp( "%s\s*\((.+)\)$" % QRegExp.escape(self.dataType) )
310-
startpos = regex.indexIn( trimmedTypeStr )
311-
if startpos >= 0:
312-
self.modifier = regex.cap(1).trimmed()
313-
else:
314-
self.modifier = None
305+
# get modifier (e.g. "precision,scale") from formatted type string
306+
trimmedTypeStr = QString(typeStr).trimmed()
307+
regex = QRegExp( "\((.+)\)$" )
308+
startpos = regex.indexIn( trimmedTypeStr )
309+
if startpos >= 0:
310+
self.modifier = regex.cap(1).trimmed()
311+
else:
312+
self.modifier = None
315313

316314
# find out whether fields are part of primary key
317315
for con in self.table().constraints():

0 commit comments

Comments
 (0)
Please sign in to comment.