Skip to content

Commit

Permalink
postgres provider: fix detection of character fields (related to #8481)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 17, 2014
1 parent 68660ac commit 24b3ed1
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/providers/postgres/qgspostgresprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,6 @@ bool QgsPostgresProvider::loadFields()
fieldSize = -1;
}
else if ( fieldTypeName == "text" ||
fieldTypeName == "bpchar" ||
fieldTypeName == "bool" ||
fieldTypeName == "geometry" ||
fieldTypeName == "hstore" ||
Expand All @@ -772,6 +771,24 @@ bool QgsPostgresProvider::loadFields()
fieldType = QVariant::String;
fieldSize = -1;
}
else if ( fieldTypeName == "bpchar" )
{
fieldType = QVariant::String;

QRegExp re( "character\\((\\d+)\\)" );
if ( re.exactMatch( formattedFieldType ) )
{
fieldSize = re.cap( 1 ).toInt();
}
else
{
QgsDebugMsg( QString( "unexpected formatted field type '%1' for field %2" )
.arg( formattedFieldType )
.arg( fieldName ) );
fieldSize = -1;
fieldPrec = -1;
}
}
else if ( fieldTypeName == "char" )
{
fieldType = QVariant::String;
Expand Down

0 comments on commit 24b3ed1

Please sign in to comment.