Skip to content
Permalink
Browse files

postgres provider: fix detection of character fields (related to #8481)

  • Loading branch information
jef-n committed Feb 17, 2014
1 parent 68660ac commit 24b3ed171be8e5895785ff2eb0edc817c5383554
Showing with 18 additions and 1 deletion.
  1. +18 −1 src/providers/postgres/qgspostgresprovider.cpp
@@ -758,7 +758,6 @@ bool QgsPostgresProvider::loadFields()
fieldSize = -1;
}
else if ( fieldTypeName == "text" ||
fieldTypeName == "bpchar" ||
fieldTypeName == "bool" ||
fieldTypeName == "geometry" ||
fieldTypeName == "hstore" ||
@@ -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;

0 comments on commit 24b3ed1

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