Bug report #11329
The new "legend format" option in graduated symbology breaks the possibility to save style inside PostgreSQL
Status: | Closed | ||
---|---|---|---|
Priority: | Severe/Regression | ||
Assignee: | - | ||
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: | Yes | Copied to github as #: | 19623 |
Description
Take a PostGIS layer and make a graduated symbology in QGIS master, then try to save the style inside the database, a message shows
Unable to save layer style. It's not possible to insert a new record into the style table. Maybe this is due to table permissions (user=curso). Please contact your database administrator.
The message is a bit misleading, in fact the QGIS log shows this message from PostreSQL:
...
...
...
</qgis>
'),XMLPARSE(DOCUMENT 'dom Out 5 09:53:46 2014'),'curso',,%12) returned 7 [ERROR: syntax error at or near "%"
LINE 1: ...e,styleQML,styleSLD,useAsDefault,description,owner%11) VALUE...
^
]
The culprit seems to be the "%" in the notation used to make the default legend format
%1 - %2
If you remove the "%" it will save the style without issues (but losing obviously the legend)
Playing around with this new feature I also got some crashes:
FAILURE: Neither -i nor -fl are specified.
Warning: Object::connect: No such signal org::freedesktop::UPower::DeviceAdded(QDBusObjectPath)
Warning: Object::connect: No such signal org::freedesktop::UPower::DeviceRemoved(QDBusObjectPath)
Warning: QObject::connect: Cannot connect (null)::rowsMoved() to QgsGraduatedSymbolRendererV2Widget::rowsMoved()
Warning: QObject::connect: Cannot connect (null)::dataChanged( QModelIndex, QModelIndex ) to QgsGraduatedSymbolRendererV2Widget::modelDataChanged( )
Warning: Object::disconnect: Unexpected null parameter
Warning: Object::disconnect: Unexpected null parameter
Warning: QObject::connect: Cannot connect (null)::rowsMoved() to QgsGraduatedSymbolRendererV2Widget::rowsMoved()
Warning: QObject::connect: Cannot connect (null)::dataChanged( QModelIndex, QModelIndex ) to QgsGraduatedSymbolRendererV2Widget::modelDataChanged( )
Warning: Object::disconnect: Unexpected null parameter
Warning: Object::disconnect: Unexpected null parameter
Warning: QObject::connect: Cannot connect (null)::rowsMoved() to QgsGraduatedSymbolRendererV2Widget::rowsMoved()
Warning: QObject::connect: Cannot connect (null)::dataChanged( QModelIndex, QModelIndex ) to QgsGraduatedSymbolRendererV2Widget::modelDataChanged( )
Warning: Object::disconnect: Unexpected null parameter
Warning: Object::disconnect: Unexpected null parameter
Warning: QObject::connect: Cannot connect (null)::rowsMoved() to QgsGraduatedSymbolRendererV2Widget::rowsMoved()
Warning: QObject::connect: Cannot connect (null)::dataChanged( QModelIndex, QModelIndex ) to QgsGraduatedSymbolRendererV2Widget::modelDataChanged( )
Warning: Object::disconnect: Unexpected null parameter
Warning: Object::disconnect: Unexpected null parameter
Fatal: ASSERT: "d" in file /usr/include/qt4/QtCore/qscopedpointer.h, line 112
QGIS died on signal -1Could not attach to process. If your uid matches the uid of the target
process, check the setting of /proc/sys/kernel/yama/ptrace_scope, or try
again as the root user. For more details, see /etc/sysctl.d/10-ptrace.conf
ptrace: Operation not permitted.
No thread selected
No stack.
gdb returned 0
Aborted
Associated revisions
History
#1 Updated by Nathan Woodrow about 10 years ago
Would something like # work?
#2 Updated by Nyall Dawson about 10 years ago
It probably just needs to be correctly escaped. I've experienced the modelDataChanged error too... I think this model should be run through the qt_modeltest routine to ensure that it's well behaved.
#3 Updated by Nathan Woodrow about 10 years ago
Do you think escaping is the way to go or will # be easy and maybe look better. That is what I'm thinking.
#4 Updated by Giovanni Manghi about 10 years ago
Nathan Woodrow wrote:
Would something like # work?
not sure. The "%" make the saving of the style fail when it used to generate one of the limits, not as a simple char. Ex: 1 fail, 1 works.
#5 Updated by Chris Crook about 10 years ago
Sounds to me like the problem is with the code saving the style into postgres - it should be able to handle any random text that is passed to it. After all, even if we use #1 (or whatever) to represent the lower and upper bounds the user may still want to have % as part of the label (indeed this is likely to be a common option).
Possibly the code is not escaping the style definition properly or something along those lines. Do you know where the code is that generates this error?
#6 Updated by Giovanni Manghi about 10 years ago
Chris Crook wrote:
Sounds to me like the problem is with the code saving the style into postgres - it should be able to handle any random text that is passed to it. After all, even if we use #1 (or whatever) to represent the lower and upper bounds the user may still want to have % as part of the label (indeed this is likely to be a common option).
Possibly the code is not escaping the style definition properly or something along those lines. Do you know where the code is that generates this error?
the query is as follow
INSERT INTO layer_styles
(f_table_catalog,f_table_schema,f_table_name,f_geometry_column,stylename,styleqml,stylesld,useasdefault,description,owner)
VALUES ...
where styleqml and stylesld
are added by using the function
XMLPARSE
to wrap style definitions
#7 Updated by Chris Crook about 10 years ago
Just on one of the other issues you've raised (disconnect and connect warnings), that is my fault and will have a fix pull request generated just as soon as it is compiled and tested. I've not got an explanation for the
FAILURE: Neither -i nor -fl are specified
or more critical
Fatal: ASSERT: "d" in file /usr/include/qt4/QtCore/qscopedpointer.h, line 112
as yet. If you can give me any clues as to how to regenerate that would be great thanks.
(Fixes submitted as pull request 1612)
#8 Updated by Chris Crook about 10 years ago
To return to the XMLPARSE, I see the code is generated by compiling and SQL string using
QString QgsPostgresConn::quotedValue( QVariant value )
rather than passing the string as a parameter to the query. So the entire query is built as a string before passing to the connection.
Can you provide the full SQL string that is generated. Then we should be able to analyse it to figure out what Postgres doesn't like and what needs to be done to fix it...
#9 Updated by Giovanni Manghi about 10 years ago
Chris Crook wrote:
I've not got an explanation for the
FAILURE: Neither -i nor -fl are specified
or more critical
Fatal: ASSERT: "d" in file /usr/include/qt4/QtCore/qscopedpointer.h, line 112
as yet. If you can give me any clues as to how to regenerate that would be great thanks.
I got the crashes while playing with this new features, changing the field for classification, legend format, deleting classes, reclassifying, etc. but they were pretty random, sorry.
#10 Updated by Giovanni Manghi about 10 years ago
Can you provide the full SQL string that is generated. Then we should be able to analyse it to figure out what Postgres doesn't like and what needs to be done to fix it...
2014-10-05T22:06:20 1 Erroneous query: INSERT INTO layer_styles(f_table_catalog,f_table_schema,f_table_name,f_geometry_column,styleName,styleQML,styleSLD,useAsDefault,description,owner%11) VALUES ('curso','public','localidades_wgs84','geom','nnnn',XMLPARSE(DOCUMENT '<!DOCTYPE qgis PUBLIC ''http://mrcc.com/qgis.dtd'' ''SYSTEM''>
<qgis version="2.5.0-Master" minimumScale="0" maximumScale="1e+08" simplifyDrawingHints="0" minLabelScale="1" maxLabelScale="1e+08" simplifyDrawingTol="1" simplifyMaxScale="1" hasScaleBasedVisibilityFlag="0" simplifyLocal="1" scaleBasedLabelVisibilityFlag="0">
<edittypes>
<edittype widgetv2type="TextEdit" name="id">
<widgetv2config IsMultiline="0" fieldEditable="1" UseHtml="0" labelOnTop="0"/>
</edittype>
</edittypes>
<renderer-v2 attr="id" symbollevels="0" type="graduatedSymbol">
<ranges>
<range render="true" symbol="0" lower="1.000000" upper="700.200000" label=" 1 - 700 "/>
<range render="true" symbol="1" lower="700.200000" upper="1399.400000" label=" 700 - 1399 "/>
<range render="true" symbol="2" lower="1399.400000" upper="2098.600000" label=" 1399 - 2099 "/>
<range render="true" symbol="3" lower="2098.600000" upper="2797.800000" label=" 2099 - 2798 "/>
<range render="true" symbol="4" lower="2797.800000" upper="3497.000000" label=" 2798 - 3497 "/>
</ranges>
<symbols>
<symbol alpha="1" type="marker" name="0">
<layer pass="0" class="SimpleMarker" locked="0">
<prop k="angle" v="0"/>
<prop k="color" v="247,251,255,255"/>
<prop k="horizontal_anchor_point" v="1"/>
<prop k="name" v="circle"/>
<prop k="offset" v="0,0"/>
<prop k="offset_map_unit_scale" v="0,0"/>
<prop k="offset_unit" v="MM"/>
<prop k="outline_color" v="0,0,0,255"/>
<prop k="outline_style" v="solid"/>
<prop k="outline_width" v="0"/>
<prop k="outline_width_map_unit_scale" v="0,0"/>
<prop k="outline_width_unit" v="MM"/>
<prop k="scale_method" v="area"/>
<prop k="size" v="2.4"/>
<prop k="size_map_unit_scale" v="0,0"/>
<prop k="size_unit" v="MM"/>
<prop k="vertical_anchor_point" v="1"/>
</layer>
<layer pass="0" class="SimpleMarker" locked="0">
<prop k="angle" v="0"/>
<prop k="color" v="247,251,255,255"/>
<prop k="horizontal_anchor_point" v="1"/>
<prop k="name" v="circle"/>
<prop k="offset" v="0,0"/>
<prop k="offset_map_unit_scale" v="0,0"/>
<prop k="offset_unit" v="MM"/>
<prop k="outline_color" v="0,0,0,255"/>
<prop k="outline_style" v="solid"/>
<prop k="outline_width" v="0"/>
<prop k="outline_width_map_unit_scale" v="0,0"/>
<prop k="outline_width_unit" v="MM"/>
<prop k="scale_method" v="area"/>
<prop k="size" v="0.5"/>
<prop k="size_map_unit_scale" v="0,0"/>
<prop k="size_unit" v="MM"/>
<prop k="vertical_anchor_point" v="1"/>
</layer>
</symbol>
<symbol alpha="1" type="marker" name="1">
<layer pass="0" class="SimpleMarker" locked="0">
<prop k="angle" v="0"/>
<prop k="color" v="199,220,239,255"/>
<prop k="horizontal_anchor_point" v="1"/>
<prop k="name" v="circle"/>
<prop k="offset" v="0,0"/>
<prop k="offset_map_unit_scale" v="0,0"/>
<prop k="offset_unit" v="MM"/>
<prop k="outline_color" v="0,0,0,255"/>
<prop k="outline_style" v="solid"/>
<prop k="outline_width" v="0"/>
<prop k="outline_width_map_unit_scale" v="0,0"/>
<prop k="outline_width_unit" v="MM"/>
<prop k="scale_method" v="area"/>
<prop k="size" v="2.4"/>
<prop k="size_map_unit_scale" v="0,0"/>
<prop k="size_unit" v="MM"/>
<prop k="vertical_anchor_point" v="1"/>
</layer>
<layer pass="0" class="SimpleMarker" locked="0">
<prop k="angle" v="0"/>
<prop k="color" v="199,220,239,255"/>
<prop k="horizontal_anchor_point" v="1"/>
<prop k="name" v="circle"/>
<prop k="offset" v="0,0"/>
<prop k="offset_map_unit_scale" v="0,0"/>
<prop k="offset_unit" v="MM"/>
<prop k="outline_color" v="0,0,0,255"/>
<prop k="outline_style" v="solid"/>
<prop k="outline_width" v="0"/>
<prop k="outline_width_map_unit_scale" v="0,0"/>
<prop k="outline_width_unit" v="MM"/>
<prop k="scale_method" v="area"/>
<prop k="size" v="0.5"/>
<prop k="size_map_unit_scale" v="0,0"/>
<prop k="size_unit" v="MM"/>
<prop k="vertical_anchor_point" v="1"/>
</layer>
</symbol>
<symbol alpha="1" type="marker" name="2">
<layer pass="0" class="SimpleMarker" locked="0">
<prop k="angle" v="0"/>
<prop k="color" v="114,178,215,255"/>
<prop k="horizontal_anchor_point" v="1"/>
<prop k="name" v="circle"/>
<prop k="offset" v="0,0"/>
<prop k="offset_map_unit_scale" v="0,0"/>
<prop k="offset_unit" v="MM"/>
<prop k="outline_color" v="0,0,0,255"/>
<prop k="outline_style" v="solid"/>
<prop k="outline_width" v="0"/>
<prop k="outline_width_map_unit_scale" v="0,0"/>
<prop k="outline_width_unit" v="MM"/>
<prop k="scale_method" v="area"/>
<prop k="size" v="2.4"/>
<prop k="size_map_unit_scale" v="0,0"/>
<prop k="size_unit" v="MM"/>
<prop k="vertical_anchor_point" v="1"/>
</layer>
<layer pass="0" class="SimpleMarker" locked="0">
<prop k="angle" v="0"/>
<prop k="color" v="114,178,215,255"/>
<prop k="horizontal_anchor_point" v="1"/>
<prop k="name" v="circle"/>
<prop k="offset" v="0,0"/>
<prop k="offset_map_unit_scale" v="0,0"/>
<prop k="offset_unit" v="MM"/>
<prop k="outline_color" v="0,0,0,255"/>
<prop k="outline_style" v="solid"/>
<prop k="outline_width" v="0"/>
<prop k="outline_width_map_unit_scale" v="0,0"/>
<prop k="outline_width_unit" v="MM"/>
<prop k="scale_method" v="area"/>
<prop k="size" v="0.5"/>
<prop k="size_map_unit_scale" v="0,0"/>
<prop k="size_unit" v="MM"/>
<prop k="vertical_anchor_point" v="1"/>
</layer>
</symbol>
<symbol alpha="1" type="marker" name="3">
<layer pass="0" class="SimpleMarker" locked="0">
<prop k="angle" v="0"/>
<prop k="color" v="40,120,184,255"/>
<prop k="horizontal_anchor_point" v="1"/>
<prop k="name" v="circle"/>
<prop k="offset" v="0,0"/>
<prop k="offset_map_unit_scale" v="0,0"/>
<prop k="offset_unit" v="MM"/>
<prop k="outline_color" v="0,0,0,255"/>
<prop k="outline_style" v="solid"/>
<prop k="outline_width" v="0"/>
<prop k="outline_width_map_unit_scale" v="0,0"/>
<prop k="outline_width_unit" v="MM"/>
<prop k="scale_method" v="area"/>
<prop k="size" v="2.4"/>
<prop k="size_map_unit_scale" v="0,0"/>
<prop k="size_unit" v="MM"/>
<prop k="vertical_anchor_point" v="1"/>
</layer>
<layer pass="0" class="SimpleMarker" locked="0">
<prop k="angle" v="0"/>
<prop k="color" v="40,120,184,255"/>
<prop k="horizontal_anchor_point" v="1"/>
<prop k="name" v="circle"/>
<prop k="offset" v="0,0"/>
<prop k="offset_map_unit_scale" v="0,0"/>
<prop k="offset_unit" v="MM"/>
<prop k="outline_color" v="0,0,0,255"/>
<prop k="outline_style" v="solid"/>
<prop k="outline_width" v="0"/>
<prop k="outline_width_map_unit_scale" v="0,0"/>
<prop k="outline_width_unit" v="MM"/>
<prop k="scale_method" v="area"/>
<prop k="size" v="0.5"/>
<prop k="size_map_unit_scale" v="0,0"/>
<prop k="size_unit" v="MM"/>
<prop k="vertical_anchor_point" v="1"/>
</layer>
</symbol>
<symbol alpha="1" type="marker" name="4">
<layer pass="0" class="SimpleMarker" locked="0">
<prop k="angle" v="0"/>
<prop k="color" v="8,48,107,255"/>
<prop k="horizontal_anchor_point" v="1"/>
<prop k="name" v="circle"/>
<prop k="offset" v="0,0"/>
<prop k="offset_map_unit_scale" v="0,0"/>
<prop k="offset_unit" v="MM"/>
<prop k="outline_color" v="0,0,0,255"/>
<prop k="outline_style" v="solid"/>
<prop k="outline_width" v="0"/>
<prop k="outline_width_map_unit_scale" v="0,0"/>
<prop k="outline_width_unit" v="MM"/>
<prop k="scale_method" v="area"/>
<prop k="size" v="2.4"/>
<prop k="size_map_unit_scale" v="0,0"/>
<prop k="size_unit" v="MM"/>
<prop k="vertical_anchor_point" v="1"/>
</layer>
<layer pass="0" class="SimpleMarker" locked="0">
<prop k="angle" v="0"/>
<prop k="color" v="8,48,107,255"/>
<prop k="horizontal_anchor_point" v="1"/>
<prop k="name" v="circle"/>
<prop k="offset" v="0,0"/>
<prop k="offset_map_unit_scale" v="0,0"/>
<prop k="offset_unit" v="MM"/>
<prop k="outline_color" v="0,0,0,255"/>
<prop k="outline_style" v="solid"/>
<prop k="outline_width" v="0"/>
<prop k="outline_width_map_unit_scale" v="0,0"/>
<prop k="outline_width_unit" v="MM"/>
<prop k="scale_method" v="area"/>
<prop k="size" v="0.5"/>
<prop k="size_map_unit_scale" v="0,0"/>
<prop k="size_unit" v="MM"/>
<prop k="vertical_anchor_point" v="1"/>
</layer>
</symbol>
</symbols>
<source-symbol>
<symbol alpha="1" type="marker" name="0">
<layer pass="0" class="SimpleMarker" locked="0">
<prop k="angle" v="0"/>
<prop k="color" v="255,255,255,255"/>
<prop k="horizontal_anchor_point" v="1"/>
<prop k="name" v="circle"/>
<prop k="offset" v="0,0"/>
<prop k="offset_map_unit_scale" v="0,0"/>
<prop k="offset_unit" v="MM"/>
<prop k="outline_color" v="0,0,0,255"/>
<prop k="outline_style" v="solid"/>
<prop k="outline_width" v="0"/>
<prop k="outline_width_map_unit_scale" v="0,0"/>
<prop k="outline_width_unit" v="MM"/>
<prop k="scale_method" v="area"/>
<prop k="size" v="2.4"/>
<prop k="size_map_unit_scale" v="0,0"/>
<prop k="size_unit" v="MM"/>
<prop k="vertical_anchor_point" v="1"/>
</layer>
<layer pass="0" class="SimpleMarker" locked="0">
<prop k="angle" v="0"/>
<prop k="color" v="0,0,0,255"/>
<prop k="horizontal_anchor_point" v="1"/>
<prop k="name" v="circle"/>
<prop k="offset" v="0,0"/>
<prop k="offset_map_unit_scale" v="0,0"/>
<prop k="offset_unit" v="MM"/>
<prop k="outline_color" v="0,0,0,255"/>
<prop k="outline_style" v="solid"/>
<prop k="outline_width" v="0"/>
<prop k="outline_width_map_unit_scale" v="0,0"/>
<prop k="outline_width_unit" v="MM"/>
<prop k="scale_method" v="area"/>
<prop k="size" v="0.5"/>
<prop k="size_map_unit_scale" v="0,0"/>
<prop k="size_unit" v="MM"/>
<prop k="vertical_anchor_point" v="1"/>
</layer>
</symbol>
</source-symbol>
<colorramp type="gradient" name="[source]">
<prop k="color1" v="247,251,255,255"/>
<prop k="color2" v="8,48,107,255"/>
<prop k="discrete" v="0"/>
<prop k="stops" v="0.13;222,235,247,255:0.26;198,219,239,255:0.39;158,202,225,255:0.52;107,174,214,255:0.65;66,146,198,255:0.78;33,113,181,255:0.9;8,81,156,255"/>
</colorramp>
<invertedcolorramp value="0"/>
<mode name="equal"/>
<rotation/>
<sizescale scalemethod="area"/>
<labelformat format=" '
<StyledLayerDescriptor xmlns="http://www.opengis.net/sld" xmlns:ogc="http://www.opengis.net/ogc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xsi:schemaLocation="http://www.opengis.net/sld http://schemas.opengis.net/sld/1.1.0/StyledLayerDescriptor.xsd" xmlns:se="http://www.opengis.net/se">
<NamedLayer>
<se:Name>localidades_wgs84</se:Name>
<UserStyle>
<se:Name>localidades_wgs84</se:Name>
<se:FeatureTypeStyle>
<se:Rule>
<se:Name> 1 - 700 </se:Name>
<se:Description>
<se:Title> 1 - 700 </se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:And>
<ogc:PropertyIsGreaterThan>
<ogc:PropertyName>id</ogc:PropertyName>
<ogc:Literal>1</ogc:Literal>
</ogc:PropertyIsGreaterThan>
<ogc:PropertyIsLessThanOrEqualTo>
<ogc:PropertyName>id</ogc:PropertyName>
<ogc:Literal>700.2</ogc:Literal>
</ogc:PropertyIsLessThanOrEqualTo>
</ogc:And>
</ogc:Filter>
<se:PointSymbolizer>
<se:Graphic>
<se:Mark>
<se:WellKnownName>circle</se:WellKnownName>
<se:Fill>
<se:SvgParameter name="fill">#f7fbff</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
</se:Stroke>
</se:Mark>
<se:Size>2.4</se:Size>
</se:Graphic>
</se:PointSymbolizer>
<se:PointSymbolizer>
<se:Graphic>
<se:Mark>
<se:WellKnownName>circle</se:WellKnownName>
<se:Fill>
<se:SvgParameter name="fill">#f7fbff</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
</se:Stroke>
</se:Mark>
<se:Size>0.5</se:Size>
</se:Graphic>
</se:PointSymbolizer>
</se:Rule>
<se:Rule>
<se:Name> 700 - 1399 </se:Name>
<se:Description>
<se:Title> 700 - 1399 </se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:And>
<ogc:PropertyIsGreaterThan>
<ogc:PropertyName>id</ogc:PropertyName>
<ogc:Literal>700.2</ogc:Literal>
</ogc:PropertyIsGreaterThan>
<ogc:PropertyIsLessThanOrEqualTo>
<ogc:PropertyName>id</ogc:PropertyName>
<ogc:Literal>1399.4</ogc:Literal>
</ogc:PropertyIsLessThanOrEqualTo>
</ogc:And>
</ogc:Filter>
<se:PointSymbolizer>
<se:Graphic>
<se:Mark>
<se:WellKnownName>circle</se:WellKnownName>
<se:Fill>
<se:SvgParameter name="fill">#c7dcef</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
</se:Stroke>
</se:Mark>
<se:Size>2.4</se:Size>
</se:Graphic>
</se:PointSymbolizer>
<se:PointSymbolizer>
<se:Graphic>
<se:Mark>
<se:WellKnownName>circle</se:WellKnownName>
<se:Fill>
<se:SvgParameter name="fill">#c7dcef</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
</se:Stroke>
</se:Mark>
<se:Size>0.5</se:Size>
</se:Graphic>
</se:PointSymbolizer>
</se:Rule>
<se:Rule>
<se:Name> 1399 - 2099 </se:Name>
<se:Description>
<se:Title> 1399 - 2099 </se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:And>
<ogc:PropertyIsGreaterThan>
<ogc:PropertyName>id</ogc:PropertyName>
<ogc:Literal>1399.4</ogc:Literal>
</ogc:PropertyIsGreaterThan>
<ogc:PropertyIsLessThanOrEqualTo>
<ogc:PropertyName>id</ogc:PropertyName>
<ogc:Literal>2098.6</ogc:Literal>
</ogc:PropertyIsLessThanOrEqualTo>
</ogc:And>
</ogc:Filter>
<se:PointSymbolizer>
<se:Graphic>
<se:Mark>
<se:WellKnownName>circle</se:WellKnownName>
<se:Fill>
<se:SvgParameter name="fill">#72b2d7</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
</se:Stroke>
</se:Mark>
<se:Size>2.4</se:Size>
</se:Graphic>
</se:PointSymbolizer>
<se:PointSymbolizer>
<se:Graphic>
<se:Mark>
<se:WellKnownName>circle</se:WellKnownName>
<se:Fill>
<se:SvgParameter name="fill">#72b2d7</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
</se:Stroke>
</se:Mark>
<se:Size>0.5</se:Size>
</se:Graphic>
</se:PointSymbolizer>
</se:Rule>
<se:Rule>
<se:Name> 2099 - 2798 </se:Name>
<se:Description>
<se:Title> 2099 - 2798 </se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:And>
<ogc:PropertyIsGreaterThan>
<ogc:PropertyName>id</ogc:PropertyName>
<ogc:Literal>2098.6</ogc:Literal>
</ogc:PropertyIsGreaterThan>
<ogc:PropertyIsLessThanOrEqualTo>
<ogc:PropertyName>id</ogc:PropertyName>
<ogc:Literal>2797.8</ogc:Literal>
</ogc:PropertyIsLessThanOrEqualTo>
</ogc:And>
</ogc:Filter>
<se:PointSymbolizer>
<se:Graphic>
<se:Mark>
<se:WellKnownName>circle</se:WellKnownName>
<se:Fill>
<se:SvgParameter name="fill">#2878b8</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
</se:Stroke>
</se:Mark>
<se:Size>2.4</se:Size>
</se:Graphic>
</se:PointSymbolizer>
<se:PointSymbolizer>
<se:Graphic>
<se:Mark>
<se:WellKnownName>circle</se:WellKnownName>
<se:Fill>
<se:SvgParameter name="fill">#2878b8</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
</se:Stroke>
</se:Mark>
<se:Size>0.5</se:Size>
</se:Graphic>
</se:PointSymbolizer>
</se:Rule>
<se:Rule>
<se:Name> 2798 - 3497 </se:Name>
<se:Description>
<se:Title> 2798 - 3497 </se:Title>
</se:Description>
<ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">
<ogc:And>
<ogc:PropertyIsGreaterThan>
<ogc:PropertyName>id</ogc:PropertyName>
<ogc:Literal>2797.8</ogc:Literal>
</ogc:PropertyIsGreaterThan>
<ogc:PropertyIsLessThanOrEqualTo>
<ogc:PropertyName>id</ogc:PropertyName>
<ogc:Literal>3497</ogc:Literal>
</ogc:PropertyIsLessThanOrEqualTo>
</ogc:And>
</ogc:Filter>
<se:PointSymbolizer>
<se:Graphic>
<se:Mark>
<se:WellKnownName>circle</se:WellKnownName>
<se:Fill>
<se:SvgParameter name="fill">#08306b</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
</se:Stroke>
</se:Mark>
<se:Size>2.4</se:Size>
</se:Graphic>
</se:PointSymbolizer>
<se:PointSymbolizer>
<se:Graphic>
<se:Mark>
<se:WellKnownName>circle</se:WellKnownName>
<se:Fill>
<se:SvgParameter name="fill">#08306b</se:SvgParameter>
</se:Fill>
<se:Stroke>
<se:SvgParameter name="stroke">#000000</se:SvgParameter>
</se:Stroke>
</se:Mark>
<se:Size>0.5</se:Size>
</se:Graphic>
</se:PointSymbolizer>
</se:Rule>
</se:FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>
' - false " trimtrailingzeroes="false" decimalplaces="0"/>
</renderer-v2>
<customproperties>
<property key="labeling" value="pal"/>
<property key="labeling/addDirectionSymbol" value="false"/>
<property key="labeling/angleOffset" value="0"/>
<property key="labeling/blendMode" value="0"/>
<property key="labeling/bufferBlendMode" value="0"/>
<property key="labeling/bufferColorA" value="255"/>
<property key="labeling/bufferColorB" value="255"/>
<property key="labeling/bufferColorG" value="255"/>
<property key="labeling/bufferColorR" value="255"/>
<property key="labeling/bufferDraw" value="false"/>
<property key="labeling/bufferJoinStyle" value="64"/>
<property key="labeling/bufferNoFill" value="false"/>
<property key="labeling/bufferSize" value="1"/>
<property key="labeling/bufferSizeInMapUnits" value="false"/>
<property key="labeling/bufferSizeMapUnitMaxScale" value="0"/>
<property key="labeling/bufferSizeMapUnitMinScale" value="0"/>
<property key="labeling/bufferTransp" value="0"/>
<property key="labeling/centroidInside" value="false"/>
<property key="labeling/centroidWhole" value="false"/>
<property key="labeling/decimals" value="3"/>
<property key="labeling/displayAll" value="false"/>
<property key="labeling/dist" value="0"/>
<property key="labeling/distInMapUnits" value="false"/>
<property key="labeling/distMapUnitMaxScale" value="0"/>
<property key="labeling/distMapUnitMinScale" value="0"/>
<property key="labeling/enabled" value="false"/>
<property key="labeling/fieldName" value="id"/>
<property key="labeling/fontBold" value="false"/>
<property key="labeling/fontCapitals" value="0"/>
<property key="labeling/fontFamily" value="DejaVu Sans"/>
<property key="labeling/fontItalic" value="false"/>
<property key="labeling/fontLetterSpacing" value="0"/>
<property key="labeling/fontLimitPixelSize" value="false"/>
<property key="labeling/fontMaxPixelSize" value="10000"/>
<property key="labeling/fontMinPixelSize" value="3"/>
<property key="labeling/fontSize" value="9"/>
<property key="labeling/fontSizeInMapUnits" value="false"/>
<property key="labeling/fontSizeMapUnitMaxScale" value="0"/>
<property key="labeling/fontSizeMapUnitMinScale" value="0"/>
<property key="labeling/fontStrikeout" value="false"/>
<property key="labeling/fontUnderline" value="false"/>
<property key="labeling/fontWeight" value="50"/>
<property key="labeling/fontWordSpacing" value="0"/>
<property key="labeling/formatNumbers" value="false"/>
<property key="labeling/isExpression" value="false"/>
<property key="labeling/labelOffsetInMapUnits" value="true"/>
<property key="labeling/labelOffsetMapUnitMaxScale" value="0"/>
<property key="labeling/labelOffsetMapUnitMinScale" value="0"/>
<property key="labeling/labelPerPart" value="false"/>
<property key="labeling/leftDirectionSymbol" value="<"/>
<property key="labeling/limitNumLabels" value="false"/>
<property key="labeling/maxCurvedCharAngleIn" value="20"/>
<property key="labeling/maxCurvedCharAngleOut" value="-20"/>
<property key="labeling/maxNumLabels" value="2000"/>
<property key="labeling/mergeLines" value="false"/>
<property key="labeling/minFeatureSize" value="0"/>
<property key="labeling/multilineAlign" value="0"/>
<property key="labeling/multilineHeight" value="1"/>
<property key="labeling/namedStyle" value="Book"/>
<property key="labeling/obstacle" value="true"/>
<property key="labeling/placeDirectionSymbol" value="0"/>
<property key="labeling/placement" value="0"/>
<property key="labeling/placementFlags" value="0"/>
<property key="labeling/plussign" value="false"/>
<property key="labeling/preserveRotation" value="true"/>
<property key="labeling/previewBkgrdColor" value="#ffffff"/>
<property key="labeling/priority" value="5"/>
<property key="labeling/quadOffset" value="4"/>
<property key="labeling/repeatDistance" value="0"/>
<property key="labeling/repeatDistanceMapUnitMaxScale" value="0"/>
<property key="labeling/repeatDistanceMapUnitMinScale" value="0"/>
<property key="labeling/repeatDistanceUnit" value="1"/>
<property key="labeling/reverseDirectionSymbol" value="false"/>
<property key="labeling/rightDirectionSymbol" value=">"/>
<property key="labeling/scaleMax" value="10000000"/>
<property key="labeling/scaleMin" value="1"/>
<property key="labeling/scaleVisibility" value="false"/>
<property key="labeling/shadowBlendMode" value="6"/>
<property key="labeling/shadowColorB" value="0"/>
<property key="labeling/shadowColorG" value="0"/>
<property key="labeling/shadowColorR" value="0"/>
<property key="labeling/shadowDraw" value="false"/>
<property key="labeling/shadowOffsetAngle" value="135"/>
<property key="labeling/shadowOffsetDist" value="1"/>
<property key="labeling/shadowOffsetGlobal" value="true"/>
<property key="labeling/shadowOffsetMapUnitMaxScale" value="0"/>
<property key="labeling/shadowOffsetMapUnitMinScale" value="0"/>
<property key="labeling/shadowOffsetUnits" value="1"/>
<property key="labeling/shadowRadius" value="1.5"/>
<property key="labeling/shadowRadiusAlphaOnly" value="false"/>
<property key="labeling/shadowRadiusMapUnitMaxScale" value="0"/>
<property key="labeling/shadowRadiusMapUnitMinScale" value="0"/>
<property key="labeling/shadowRadiusUnits" value="1"/>
<property key="labeling/shadowScale" value="100"/>
<property key="labeling/shadowTransparency" value="30"/>
<property key="labeling/shadowUnder" value="0"/>
<property key="labeling/shapeBlendMode" value="0"/>
<property key="labeling/shapeBorderColorA" value="255"/>
<property key="labeling/shapeBorderColorB" value="128"/>
<property key="labeling/shapeBorderColorG" value="128"/>
<property key="labeling/shapeBorderColorR" value="128"/>
<property key="labeling/shapeBorderWidth" value="0"/>
<property key="labeling/shapeBorderWidthMapUnitMaxScale" value="0"/>
<property key="labeling/shapeBorderWidthMapUnitMinScale" value="0"/>
<property key="labeling/shapeBorderWidthUnits" value="1"/>
<property key="labeling/shapeDraw" value="false"/>
<property key="labeling/shapeFillColorA" value="255"/>
<property key="labeling/shapeFillColorB" value="255"/>
<property key="labeling/shapeFillColorG" value="255"/>
<property key="labeling/shapeFillColorR" value="255"/>
<property key="labeling/shapeJoinStyle" value="64"/>
<property key="labeling/shapeOffsetMapUnitMaxScale" value="0"/>
<property key="labeling/shapeOffsetMapUnitMinScale" value="0"/>
<property key="labeling/shapeOffsetUnits" value="1"/>
<property key="labeling/shapeOffsetX" value="0"/>
<property key="labeling/shapeOffsetY" value="0"/>
<property key="labeling/shapeRadiiMapUnitMaxScale" value="0"/>
<property key="labeling/shapeRadiiMapUnitMinScale" value="0"/>
<property key="labeling/shapeRadiiUnits" value="1"/>
<property key="labeling/shapeRadiiX" value="0"/>
<property key="labeling/shapeRadiiY" value="0"/>
<property key="labeling/shapeRotation" value="0"/>
<property key="labeling/shapeRotationType" value="0"/>
<property key="labeling/shapeSVGFile" value=""/>
<property key="labeling/shapeSizeMapUnitMaxScale" value="0"/>
<property key="labeling/shapeSizeMapUnitMinScale" value="0"/>
<property key="labeling/shapeSizeType" value="0"/>
<property key="labeling/shapeSizeUnits" value="1"/>
<property key="labeling/shapeSizeX" value="0"/>
<property key="labeling/shapeSizeY" value="0"/>
<property key="labeling/shapeTransparency" value="0"/>
<property key="labeling/shapeType" value="0"/>
<property key="labeling/textColorA" value="255"/>
<property key="labeling/textColorB" value="0"/>
<property key="labeling/textColorG" value="0"/>
<property key="labeling/textColorR" value="0"/>
<property key="labeling/textTransp" value="0"/>
<property key="labeling/upsidedownLabels" value="0"/>
<property key="labeling/wrapChar" value=""/>
<property key="labeling/xOffset" value="0"/>
<property key="labeling/yOffset" value="0"/>
</customproperties>
<blendMode>0</blendMode>
<featureBlendMode>0</featureBlendMode>
<layerTransparency>0</layerTransparency>
<displayfield>CODE</displayfield>
<label>0</label>
<labelattributes>
<label fieldname="" text="Etichetta"/>
<family fieldname="" name="MS Shell Dlg 2"/>
<size fieldname="" units="pt" value="12"/>
<bold fieldname="" on="0"/>
<italic fieldname="" on="0"/>
<underline fieldname="" on="0"/>
<strikeout fieldname="" on="0"/>
<color fieldname="" red="0" blue="0" green="0"/>
<x fieldname=""/>
<y fieldname=""/>
<offset x="0" y="0" units="pt" yfieldname="" xfieldname=""/>
<angle fieldname="" value="0" auto="0"/>
<alignment fieldname="" value="center"/>
<buffercolor fieldname="" red="255" blue="255" green="255"/>
<buffersize fieldname="" units="pt" value="1"/>
<bufferenabled fieldname="" on=""/>
<multilineenabled fieldname="" on=""/>
<selectedonly on=""/>
</labelattributes>
<editform></editform>
<editforminit></editforminit>
<featformsuppress>0</featformsuppress>
<annotationform></annotationform>
<editorlayout>generatedlayout</editorlayout>
<excludeAttributesWMS/>
<excludeAttributesWFS/>
<attributeactions/>
</qgis>
'),XMLPARSE,'curso',,%12) returned 7 [ERROR: syntax error at or near "%"
LINE 1: ...e,styleQML,styleSLD,useAsDefault,description,owner%11) VALUE...
^
]
#11 Updated by Chris Crook about 10 years ago
Ok - I see where the problem is coming from. The provider is building SQL strings using the QString.arg function using the pattern
QString sql=QString("INSERT INTO layer_styles(...) VALUES (%1,%2,%3,...)")
.arg(value1)
.arg(value2)
...
;
The .arg function replaces the sequence %# or %## (where # is a digit) with its argument, and returns the new string.
The problem here is that one of the replacement strings contains %1. So in the example above, if the replacement string value1 includes the text '%1', then the second .arg call will replace this with the value2 argument.
You could argue that this is a design flaw in QString.arg. Certainly this pattern (.arg().arg().arg()) is unsafe. The QString.arg function can be replaced with a single .arg(value1,value2,value3...), but that only handles up to 9 arguments - not enough in this case.
I think the only safe way to implement this is to explicitly build the sql strings, rather than use string replacement functions. This isn't as clean to look at (ie it is harder to see what the original SQL looks like), but it is the easiest way I can see to ensure that arbitrary string values can be included in the SQL. That is, the code ends up looking like
... VALUES ( "+
QgsPostgresConn::quotedValue(value1)+","
QgsPostgresConn::quotedValue(value2)+","
QgsPostgresConn::quotedValue(value3)+","
...
")";
or better to use PQexecPrepared, and avoid the quoting altogether (but I'm not sure about how to handle type conversions with this option)
#12 Updated by Chris Crook about 10 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
This issue is fixed by pull request #1615.
I've used a "minimal change" approach - so the qml and sld strings are inserted into the SQL strings by the final .arg function call.
==================
The other issues raised by this request are either fixed (the warnings) or not reproducible. It is possible that the fix that removed the warnings (correct initiallization of the QgsGraduatedSymbolRendererV2Model in the widget) may have addressed the unreproducible issues also.
#13 Updated by Paolo Cavallini about 10 years ago
- Status changed from Closed to Feedback
Does the patch handle backward compatibility?
#14 Updated by Chris Crook about 10 years ago
The patch is a minimal change - so completely compatible. The only thing it changes is how the style insert/update SQL strings are constructed (in fact just the order that values are inserted into the string) to ensure that the final SQL string constructed is as intended.
#15 Updated by Paolo Cavallini about 10 years ago
- Status changed from Feedback to Closed
OK, closing it then. Thanks.
#16 Updated by Chris Crook about 10 years ago
- Status changed from Closed to Reopened
In retrospect think I should have left this open until the pull request is actually applied...
#17 Updated by Jürgen Fischer about 10 years ago
- Status changed from Reopened to Closed
Fixed in changeset 34ccc8173e5344681b72b02fa27ef10f7a411cbc.