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
Erroneous query: zero-length delimited identifier at or near """" #15339
Comments
Author Name: Paolo Cavallini (@pcav)
|
Author Name: Giuseppe Sucameli (@brushtyler) It's a bug on the PG provider. The schema part is added also for queries (a check is missing).
|
Author Name: Jürgen Fischer (@jef-n)
Can you reproduce the problem with something that doesn't need the latest postgis? BTW you should "visually" see the error in the message log (and the popup over the in the main window status bar). |
Author Name: James Stott (@jamesstott) I have changed my code slightly from the original code I posted on the mailing list and I get a slightly different error: This query works and adds a layer into QGIS: @uri.setDataSource('',"(SELECT int4(row_number() OVER ()) AS id,ST_GeomFromText('POINT(451583 129144)',27700) As geom)", "geom",'',"id")@ The following doesn't work: @uri.setDataSource('',"(SELECT * From \"designations\".\"table\" where ST_DWithin(ST_GeomFromText('POINT(451583 129144)',27700), \"table\".\"geom\", 2000)", "geom",'',"gid")@ This gives the following error: @unABLE to execute the query. Does seem like there is an extra SELECT statement added to the from of the query as it says SELECT * FROM (SELECT * From. The from in my code is From not FROM. |
Author Name: Jürgen Fischer (@jef-n) James Stott wrote:
And that's not just because the closing paren is missing after "2000)"? |
Author Name: James Stott (@jamesstott) Adding the ) leads to this error: Unable to execute the query. |
Author Name: Jürgen Fischer (@jef-n) James Stott wrote:
Please check the syntax again. Looks like you misplaced the @"@ this time ;) |
Author Name: James Stott (@jamesstott) Apologies, it was a syntax problem. This worked: |
Author Name: Paolo Cavallini (@pcav)
|
Author Name: Giuseppe Sucameli (@brushtyler) Jürgen Fischer wrote:
strk, could you please provide more info?
|
Author Name: Sandro Santilli (@strk) This query doesn't need the latest postgis, nor any table:
Try it, replacing "unioned" and "wrongsnap" with a valid geometry column and table name.
I still tried trough the DBManager, don't know if it's possible (or how) to reproduce directly against the PostGIS Data Provider. Maybe Giuseppe knows ? |
Author Name: Giuseppe Sucameli (@brushtyler) Sandro Santilli wrote:
Try the following code from QGis Python Console:
|
Author Name: Jürgen Fischer (@jef-n) Giuseppe Sucameli wrote:
Should that reproduce the problem? Because it doesn't here. |
Author Name: Giuseppe Sucameli (@brushtyler) Jürgen Fischer wrote:
I know, neither here. But that code is quite identical to the one used in DBManager. |
Author Name: Sandro Santilli (@strk) I've no time to debug this. Can't you reproduce it there Giuseppe ? |
Author Name: Giuseppe Sucameli (@brushtyler) Sandro Santilli wrote:
Not reproduced yet, anyway I've found it. The problem is at https://github.com/qgis/Quantum-GIS/blob/master/src/providers/postgres/qgspostgresconn.cpp#L1027, so you're using estimated metadata for the connection. @jef: I've assigned the ticket to you, I don't know how to handle estimated metadata option together with queries.
|
Author Name: Sandro Santilli (@strk) No way to estimate extent of a query. You must necessarely run it. |
Author Name: Sandro Santilli (@strk) |
Author Name: Giuseppe Sucameli (@brushtyler)
It works until the "use table estimated metadata" option is checked in the connection settings, in that case I get the following error: Erroneous query: SELECT DISTINCT CASE WHEN upper(geometrytype("geom")) IN ('POINT','MULTIPOINT','POINTM','MULTIPOINTM') THEN 'POINT' WHEN upper(geometrytype("geom")) IN ('LINESTRING','MULTILINESTRING','LINESTRINGM','MULTILINESTRINGM') THEN 'LINESTRING' WHEN upper(geometrytype("geom")) IN ('POLYGON','MULTIPOLYGON','POLYGONM','MULTIPOLYGONM') THEN 'POLYGON' END, st_srid("geom") FROM (SELECT "geom" FROM ""."(select 1 as id, (ST_Dump(ST_ConvexHull(st_collect('POINT(0 0)'::geometry)))).* FROM ""province"" EDIT: the problem occurs also with very simple queries like:
|
Author Name: Jürgen Fischer (@jef-n) Fixed in changeset "6aa7524482f176aaf603ff47b171a1c3e3c2fc62".
|
Author Name: Sandro Santilli (@strk)
Original Redmine Issue: 5883
Affected QGIS version: 1.8.0
Redmine category:data_provider/postgis
Assignee: Jürgen Fischer
SQL window, retriving the data worked, loading as layer didn't (but didn't visually report any error)
Error/debug on the console:
The text was updated successfully, but these errors were encountered: