Skip to content

Commit

Permalink
db_manager: get fields' size from formatted type string (fix #6402)
Browse files Browse the repository at this point in the history
  • Loading branch information
brushtyler committed Oct 2, 2012
1 parent c74090d commit 99876cc
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions python/plugins/db_manager/db_plugins/postgis/plugin.py
Expand Up @@ -302,16 +302,14 @@ def __init__(self, row, table):
self.num, self.name, self.dataType, self.charMaxLen, self.modifier, self.notNull, self.hasDefault, self.default, typeStr = row
self.primaryKey = False

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

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

0 comments on commit 99876cc

Please sign in to comment.