Skip to content
Permalink
Browse files

db_manager: get fields' size from formatted type string (fix #6402)

  • Loading branch information
brushtyler committed Oct 2, 2012
1 parent c74090d commit 99876ccb4594fec2cf09291049b63ca4fe7b2ee0
Showing with 8 additions and 10 deletions.
  1. +8 −10 python/plugins/db_manager/db_plugins/postgis/plugin.py
@@ -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():

0 comments on commit 99876cc

Please sign in to comment.
You can’t perform that action at this time.