Skip to content
Permalink
Browse files
expressions: only quote when necessary (fixes tests; followup 915f5c1)
  • Loading branch information
jef-n committed Feb 9, 2014
1 parent 83d2b61 commit f3b26494934beb5c5b0b6158356dad4fe02da508
Showing with 6 additions and 2 deletions.
  1. +1 −1 src/core/qgsexpression.cpp
  2. +1 −1 src/core/qgsvectorlayereditbuffer.cpp
  3. +4 −0 tests/src/python/test_qgsexpression.py
@@ -2266,7 +2266,7 @@ bool QgsExpression::NodeColumnRef::prepare( QgsExpression* parent, const QgsFiel

QString QgsExpression::NodeColumnRef::dump() const
{
return quotedColumnRef( mName );
return QRegExp( "^[A-Za-z_\x80-\xff][A-Za-z0-9_\x80-\xff]*$" ).exactMatch( mName ) ? mName : quotedColumnRef( mName );
}

//
@@ -40,7 +40,7 @@ bool QgsVectorLayerEditBuffer::isModified() const

void QgsVectorLayerEditBuffer::undoIndexChanged( int index )
{
qDebug( "undo index changed %d", index );
QgsDebugMsg( QString( "undo index changed %1" ).arg( index ) );
Q_UNUSED( index );
emit layerModified();
}
@@ -83,5 +83,9 @@ def testCantOverrideBuiltinsWithUnregister(self):
success = QgsExpression.unregisterFunction("sqrt")
self.assertFalse(success)

def testDump(self):
for txt in ["id", u"idä", "\"id abc\"", "\"id abc\""]:
self.assertEqual( txt, QgsExpression(txt).expression() )

if __name__ == "__main__":
unittest.main()

0 comments on commit f3b2649

Please sign in to comment.