From 79572d3e09a5d2494f6746c763e73d10b9608175 Mon Sep 17 00:00:00 2001 From: rabla Date: Wed, 15 Jun 2005 13:33:24 +0000 Subject: [PATCH] escape apostrophe, use null if text is empty git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@3603 c8812cc2-4d05-0410-92ff-de0c093fc19c --- plugins/grass/qgsgrassattributes.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/plugins/grass/qgsgrassattributes.cpp b/plugins/grass/qgsgrassattributes.cpp index dae8aabc2a3..5b51d3e5a86 100644 --- a/plugins/grass/qgsgrassattributes.cpp +++ b/plugins/grass/qgsgrassattributes.cpp @@ -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 + "'" ); + } } }