Skip to content

Commit

Permalink
fix #2250
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk@12404 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Dec 11, 2009
1 parent 1c6d7b5 commit 76ceea8
Showing 1 changed file with 30 additions and 32 deletions.
62 changes: 30 additions & 32 deletions src/providers/spatialite/qgsspatialiteprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ bool QgsSpatiaLiteProvider::featureAtId( int featureId, QgsFeature & feature, bo
const QString & fieldname = fld.name();
sql += ", \"";
sql += fieldname;
sql += "\"";
sql += "\"";
}
if ( fetchGeometry )
{
Expand Down Expand Up @@ -526,7 +526,7 @@ void QgsSpatiaLiteProvider::select( QgsAttributeList fetchAttributes, QgsRectang
const QString & fieldname = fld.name();
sql += ", \"";
sql += fieldname;
sql += "\"";
sql += "\"";
}
if ( fetchGeometry )
{
Expand Down Expand Up @@ -872,14 +872,12 @@ void QgsSpatiaLiteProvider::uniqueValues( int index, QList < QVariant > &uniqueV
uniqueValues.append( QString( "%1" ).arg( sqlite3_column_double( stmt, 0 ) ) );
break;
case SQLITE_TEXT:
txt = ( const char * ) sqlite3_column_text( stmt, 0 );
uniqueValues.append( txt );
uniqueValues.append( QString::fromUtf8(( const char * ) sqlite3_column_text( stmt, 0 ) ) );
break;
default:
txt = "";
uniqueValues.append( txt );
uniqueValues.append( "" );
break;
};
}
}
else
{
Expand Down Expand Up @@ -952,7 +950,7 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )

sql += ", \"";
sql += fieldname;
sql += "\"";
sql += "\"";
values += ", ?";
}

Expand Down Expand Up @@ -1033,7 +1031,7 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )
// performing actual row insert
ret = sqlite3_step( stmt );

if ( ret == SQLITE_DONE || ret == SQLITE_ROW )
if ( ret == SQLITE_DONE || ret == SQLITE_ROW )
{
numberFeatures++;
}
Expand Down Expand Up @@ -1254,29 +1252,29 @@ bool QgsSpatiaLiteProvider::changeAttributeValues( const QgsChangedAttributesMap
sql += ",";
else
first = false;
QVariant::Type type = siter->type();
if ( siter->toString().isEmpty() )
{
// assuming to be a NULL value
type = QVariant::Invalid;
}

if ( type == QVariant::Invalid )
{
// binding a NULL value
sql += QString( "\"%1\"=NULL" ).arg( fieldName );
}
else if ( type == QVariant::Int || type == QVariant::Double )
{
// binding a NUMERIC value
sql += QString( "\"%1\"=%2" ).arg( fieldName ).arg( siter->toString() );
}
else
{
// binding a TEXT value
sql += QString( "\"%1\"=%2" ).arg( fieldName ).arg( quotedValue( siter->toString() ) );
}

QVariant::Type type = siter->type();
if ( siter->toString().isEmpty() )
{
// assuming to be a NULL value
type = QVariant::Invalid;
}

if ( type == QVariant::Invalid )
{
// binding a NULL value
sql += QString( "\"%1\"=NULL" ).arg( fieldName );
}
else if ( type == QVariant::Int || type == QVariant::Double )
{
// binding a NUMERIC value
sql += QString( "\"%1\"=%2" ).arg( fieldName ).arg( siter->toString() );
}
else
{
// binding a TEXT value
sql += QString( "\"%1\"=%2" ).arg( fieldName ).arg( quotedValue( siter->toString() ) );
}
}
sql += QString( " WHERE ROWID=%1" ).arg( fid );

Expand Down

0 comments on commit 76ceea8

Please sign in to comment.