escape apostrophe, use null if text is empty

git-svn-id: http://svn.osgeo.org/qgis/trunk@3603 c8812cc2-4d05-0410-92ff-de0c093fc19c
This commit is contained in:
rabla 2005-06-15 13:33:24 +00:00
parent de041a542b
commit 2d1e8bf206

View File

@ -252,12 +252,20 @@ void QgsGrassAttributes::updateAttributes ( )
for ( int i = 2; i < tb->numRows(); i++ ) {
if ( i > 2 ) sql.append (", ");
if ( tb->text(i, 2) == "int" || tb->text(i, 2) == "double" ) {
sql.append ( tb->text(i, 0) + " = " + tb->text(i, 1) );
} else {
QString val = tb->text(i, 1);
val.replace("'","''");
sql.append ( tb->text(i, 0) + " = '" + tb->text(i, 1) + "'" );
QString val = tb->text(i, 1).stripWhiteSpace();
if ( val.isEmpty() )
{
sql.append ( tb->text(i, 0) + " = null" );
}
else
{
if ( tb->text(i, 2) == "int" || tb->text(i, 2) == "double" ) {
sql.append ( tb->text(i, 0) + " = " + val );
} else {
val.replace("'","''");
sql.append ( tb->text(i, 0) + " = '" + val + "'" );
}
}
}