Skip to content

Commit eb9a22e

Browse files
committed
Dump CASE correctly in QgsExpression::dump()
1 parent 578a83a commit eb9a22e

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/core/qgsexpression.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,13 +2315,14 @@ bool QgsExpression::NodeCondition::prepare( QgsExpression* parent, const QgsFiel
23152315

23162316
QString QgsExpression::NodeCondition::dump() const
23172317
{
2318-
QString msg = "CONDITION:\n";
2318+
QString msg = QString("CASE ");
23192319
foreach ( WhenThen* cond, mConditions )
23202320
{
2321-
msg += QString( "- WHEN %1 THEN %2\n" ).arg( cond->mWhenExp->dump() ).arg( cond->mThenExp->dump() );
2321+
msg += QString( "WHEN %1 THEN %2" ).arg( cond->mWhenExp->dump() ).arg( cond->mThenExp->dump() );
23222322
}
23232323
if ( mElseExp )
2324-
msg += QString( "- ELSE %1" ).arg( mElseExp->dump() );
2324+
msg += QString( "ELSE %1" ).arg( mElseExp->dump() );
2325+
msg += QString(" END");
23252326
return msg;
23262327
}
23272328

src/core/qgsexpression.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,9 @@ class CORE_EXPORT QgsExpression
152152

153153
int scale() {return mScale; }
154154

155-
//! Return the expression string that was given when created.
156-
const QString expression() const { return mExp; }
155+
const QString expression() const { return dump(); }
157156

158-
//! Return the a debugging string of the expression.
159-
//! This can be used for debugging. Use {@link expression()}
160-
//! if you need the full expression string.
157+
//! Return the expression string that represents this QgsExpression.
161158
QString dump() const;
162159

163160
//! Return calculator used for distance and area calculations

0 commit comments

Comments
 (0)