Skip to content

Commit

Permalink
expressions: only quote when necessary (fixes tests; followup 915f5c1)
Browse files Browse the repository at this point in the history
  • Loading branch information
jef-n committed Feb 9, 2014
1 parent 83d2b61 commit f3b2649
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/core/qgsexpression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}

//
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsvectorlayereditbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
4 changes: 4 additions & 0 deletions tests/src/python/test_qgsexpression.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.