Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expression parser: some expressions evaluate to NULL when they shouldn't #14373

Closed
qgib opened this issue Oct 24, 2011 · 6 comments
Closed

Expression parser: some expressions evaluate to NULL when they shouldn't #14373

qgib opened this issue Oct 24, 2011 · 6 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Vectors Related to general vector layer handling (not specific data formats)

Comments

@qgib
Copy link
Contributor

qgib commented Oct 24, 2011

Author Name: Alister Hood (@AlisterH)
Original Redmine Issue: 4441

Redmine category:vectors
Assignee: Martin Dobias


example 1:
I can create a string attribute field called "test1" and fill it using @$perimeter@
I can then fill it using @toint(test1)@
But the entire column is set to NULL if I try to do this in one step using @toint($perimeter)@

example 2:
With the new expression based labelling in Trunk, with some expressions the result displays OK in the "expression based label" window's preview, but no labels are drawn on the canvas. e.g. this expression: @toreal(toint($AREA/100))/100@

But for some reason I can build a larger expression which includes it, and the labels are drawn successfully:
CNAME || '
SMU '|| CNUMBER || '
AREA = ' || tostring(toreal(toint($AREA/100))/100) || ' ha'

@qgib
Copy link
Contributor Author

qgib commented Oct 24, 2011

Author Name: Nathan Woodrow (@NathanW2)


I have just changed the title because it's related to the underlying expression parser more then anything else.


  • must_fix was changed from to Yes
  • subject was changed from Labelling/Field calculator: some expressions evaluate to NULL when they shouldn't to Expression parser: some expressions evaluate to NULL when they shouldn't
  • assigned_to_id was configured as Martin Dobias

@qgib
Copy link
Contributor Author

qgib commented Nov 2, 2011

Author Name: Martin Dobias (@wonder-sk)


Fixed in 699694


  • resolution was changed from to fixed
  • status_id was changed from Open to Closed

@qgib
Copy link
Contributor Author

qgib commented Nov 2, 2011

Author Name: Alister Hood (@AlisterH)


I guess I should maybe open a new ticket - there is still be a problem for labelling.

As far as I can tell, the field calculator is working correctly, e.g. I can now fill a field with @toint($perimeter)@, or @regexp_replace( toint($area) ,'(\\d+)(\\d{3})','\\1,\\2')@, and I can label with fields created that way.

But if I try to use either of those expressions for labelling, the label is shown correctly in the output preview, but no labels are drawn on the map.

@qgib
Copy link
Contributor Author

qgib commented Nov 2, 2011

Author Name: Alister Hood (@AlisterH)


Actually, it seems like the labelling doesn't work with any expression except a field name. e.g. no labels are shown if I use the expression @1@ or @1+1@ or @$perimeter@

@qgib
Copy link
Contributor Author

qgib commented Nov 2, 2011

Author Name: Nathan Woodrow (@NathanW2)


I noticed this too. I think I know what might be causing the issue.

My guess is that how I'm using QgsExpression::evaluate() is wrong.

In the widget I use:

QVariant value = exp.evaluate( &feature, mLayer->pendingFields() );
</code>

but in the labeling class I use:

QVariant result = exp->evaluate( &f, layer->dataProvider()->fields() );
</code>

Will patch it and see if that makes any difference.

@qgib
Copy link
Contributor Author

qgib commented Nov 4, 2011

Author Name: Nathan Woodrow (@NathanW2)


Opened a new ticket at #14418 and supplied a patch.

@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Vectors Related to general vector layer handling (not specific data formats) labels May 24, 2019
@qgib qgib closed this as completed May 24, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Vectors Related to general vector layer handling (not specific data formats)
Projects
None yet
Development

No branches or pull requests

1 participant