Skip to content

Commit

Permalink
fix crash in postgres layer creation (followup 3470b1d; fixes #10014)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed May 31, 2014
1 parent 873ec8c commit f4545d9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/providers/postgres/qgspostgresprovider.cpp
Expand Up @@ -2780,7 +2780,7 @@ bool QgsPostgresProvider::convertField( QgsField &field , const QMap<QString, QV
{
//determine field type to use for strings
QString stringFieldType = "varchar";
if ( options->contains( "dropStringConstraints" ) && options->value( "dropStringConstraints" ).toBool() )
if ( options && options->value( "dropStringConstraints", false ).toBool() )
{
//drop string length constraints by using PostgreSQL text type for strings
stringFieldType = "text";
Expand Down Expand Up @@ -2970,7 +2970,7 @@ QgsVectorLayerImport::ImportError QgsPostgresProvider::createEmptyLayer(
throw PGException( result );
}

if ( options->contains( "lowercaseFieldNames" ) && options->value( "lowercaseFieldNames" ).toBool() )
if ( options && options->value( "lowercaseFieldNames", false ).toBool() )
{
//convert primary key name to lowercase
//this must happen after determining the field type of the primary key
Expand Down Expand Up @@ -3065,7 +3065,7 @@ QgsVectorLayerImport::ImportError QgsPostgresProvider::createEmptyLayer(
continue;
}

if ( options->contains( "lowercaseFieldNames" ) && options->value( "lowercaseFieldNames" ).toBool() )
if ( options && options->value( "lowercaseFieldNames", false ).toBool() )
{
//convert field name to lowercase
fld.setName( fld.name().toLower() );
Expand Down

0 comments on commit f4545d9

Please sign in to comment.