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

Syntactical error with the use of == instead of = for comparison in the WHERE clause. #54608

Closed
2 tasks done
dotsLand opened this issue Sep 15, 2023 · 1 comment
Closed
2 tasks done
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter!

Comments

@dotsLand
Copy link

dotsLand commented Sep 15, 2023

What is the bug or the crash?

Issue Summary:
On a warning message was generated in QGIS due to an erroneous SQL query. The query attempted to retrieve data from the layer_styles table, but it contained a syntactical error with the use of == instead of = for comparison in the WHERE clause. As a result, the query failed to execute, leading to the reported error.

Error Details:

2023-09-15T00:05:58     WARNING    NOTICE: row number 0 is out of range 0..-1
2023-09-15T09:31:54     WARNING    Erroneous query: SELECT styleName FROM layer_styles WHERE f_table_catalog='knffis32' AND f_table_schema='kca' AND f_table_name='adm_rks_border' AND f_geometry_column=='geom' AND (type='Polygon' OR type IS NULL) AND styleName='Kufijt Administrative' returned 7 [ERROR: operator does not exist: character varying == unknown
             LINE 1: ..._table_name='adm_rks_border' AND f_geometry_column=='geom' A...
              ^
             HINT: No operator matches the given name and argument types. You might need to add explicit type casts.
             ]

image

Date and Time: [Date and Time]
Error Level: WARNING
Error Message: Erroneous query: SELECT styleName FROM layer_styles WHERE f_table_catalog='knffis32' AND f_table_schema='kca' AND f_table_name='adm_rks_border' AND f_geometry_column=='geom' AND (type='Polygon' OR type IS NULL) AND styleName='Kufijt Administrative' returned 7 [ERROR: operator does not exist: character varying == unknown
LINE 1: ..._table_name='adm_rks_border' AND f_geometry_column=='geom' A...
HINT: No operator matches the given name and argument types. You might need to add explicit type casts.]
Root Cause:
The root cause of this issue is the use of == for comparison in the SQL query, which is not a valid operator in SQL. In SQL, the correct operator for equality comparison is =.

Impact:
The impact of this error is that the SQL query cannot be executed successfully, and it results in a database error. This may lead to incorrect or missing data in QGIS when attempting to retrieve styles for the specified table and geometry column.

Resolution:
To resolve this issue, the SQL query should be modified to use the correct equality operator (=) instead of ==.

Steps to reproduce the issue

  1. Save one QGIS Style into Postgresql Database
  2. load layer from database in QGIS

Versions

QGIS version
3.28.10-Firenze
QGIS code revision
e2edb9c

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

No response

@dotsLand dotsLand added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Sep 15, 2023
@rouault
Copy link
Contributor

rouault commented Sep 17, 2023

This has been fixed 2 weeks ago per 3ed6e10 and should be available in 3.28.11

@rouault rouault closed this as completed Sep 17, 2023
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!
Projects
None yet
Development

No branches or pull requests

2 participants