Bug report #9783

Data defined properties expressions are wrong after saving them

Added by Tudor Bărăscu over 10 years ago. Updated over 10 years ago.

Status:Closed
Priority:Severe/Regression
Assignee:Jürgen Fischer
Category:Symbology
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:
Crashes QGIS or corrupts data:No Copied to github as #:18325

Description

On a pipe layer I'm using data defined properties to style the width of the line according to the diameter.

For the case when I have a "diameter_nominal" from a joined field:
In QGIS >= Dufour: "diameter_nominal" / 400 + 0.5 gets saved as diameter_nominal / 400 + 0.5 and does NOT work.

If I work with a field from the actual table everything works but I noticed that:
In QGIS >= Valmiera: "diameter" / 400 + 0.5 gets saved like diameter / 400 + 0.5

-- Notice the quotes don't get saved in QGIS >= 2.2 and I think they should.

All the best,
Tudor

If I only fill the field with "diameter_nominal" it gets saved as it should ("diameter_nominal") but I need to be able to use the fields from the joined table in formulas.

When working in the labels expression builder everything works. The problem is present only in the data defined properties expression builder.

Associated revisions

Revision b6b78ca7
Added by Jürgen Fischer over 10 years ago

expression: dump binary operations with brackets to break precedence (fixes #9783)

Revision 4e49ad54
Added by Jürgen Fischer over 10 years ago

data defined symbol dialog: only remove quoting if there is one (fixes #9783)

History

#1 Updated by Tudor Bărăscu over 10 years ago

It seems this is all because the diameter field is numeric type and the other int type.

The solution is to have the expression like this.
toreal("diameter_nominal")/400 + 0.5

I don't know anymore if this is intended or a bug.

#2 Updated by Tudor Bărăscu over 10 years ago

Although this worked before (QGIS 2.0):
0.2 + toint(substr(regexp_substr('600900', '(0[1-9]\\\\d+)'),2,4))/900

The data defined properties box shows the correct result in the output preview (1.2) but after I save the expression
it saves it as:

0.2 + toint(substr(regexp_substr('600900', '(0[1-9]?+)'), 2, 4)) / 900

Notice that the \\\\d gets replaced with ? after saving and when reopening again it throws the invalid expression error in red.

#3 Updated by Giovanni Manghi over 10 years ago

  • Operating System deleted (Windows 7 64 bit)
  • Affected QGIS version changed from 2.2.0 to master
  • Target version set to Version 2.4
  • Priority changed from Normal to Severe/Regression
  • Subject changed from Data defined properties does not work with fields from joined tables in QGIS >= 2.0 to Data defined properties expressions are wrong after saving them

The issue was confirmed/discussed also here

http://lists.osgeo.org/pipermail/qgis-developer/2014-March/031547.html

and it is indeed a regression as in 2.0.1 works as expected.

#4 Updated by Jürgen Fischer over 10 years ago

  • Assignee set to Jürgen Fischer

#5 Updated by Jürgen Fischer over 10 years ago

  • Status changed from Open to Closed

#6 Updated by Giovanni Manghi over 10 years ago

  • Status changed from Closed to Reopened

sorry to reopen this, it seems there is still something odd. This is what I notice:

  • quotation marks are stripped from columns names
  • as noticed in #9823 in expressions with single numbers those are stripped
  • the proposed workaround (ex: 10-0) serve only to make the expression stick, but the result is wrong (wrong symbol size)

#7 Updated by Jürgen Fischer over 10 years ago

Giovanni Manghi wrote:

sorry to reopen this, it seems there is still something odd. This is what I notice:

  • quotation marks are stripped from columns names

That's ok.

  • as noticed in #9823 in expressions with single numbers those are stripped

Unrelated to the original report, but the first and last character were removed even if the expression wasn't quoted - producing an empty expression for everything shorter that two characters.

#8 Updated by Jürgen Fischer over 10 years ago

  • Status changed from Reopened to Closed

Also available in: Atom PDF