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

SQL Server Spatial support broken in 3.22 #46907

Closed
2 tasks done
oacmose opened this issue Jan 20, 2022 · 1 comment · Fixed by #46923
Closed
2 tasks done

SQL Server Spatial support broken in 3.22 #46907

oacmose opened this issue Jan 20, 2022 · 1 comment · Fixed by #46923
Assignees
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! MS SQL data provider Regression Something which used to work, but doesn't anymore

Comments

@oacmose
Copy link

oacmose commented Jan 20, 2022

What is the bug or the crash?

SQL Server spatial tables no longer display in QGIS.

Steps to reproduce the issue

  1. Use the attached SQL script to create a very simple SQL Server database containing a single spatial table.
  2. In QGIS create a new MS SQL Server connection selecting the database created in step one. (Be sure to untick "Only look in the geometry_columns metadata table"
  3. Expand your new connection and expand the dbo schema
  4. Open the table "POINTS"
    Nothing is displayed. Profiling the SQL shows a malformed SQL statement:
    SELECT ,[OBJ] FROM [dbo].[POINTS] WHERE [OBJ].STIsValid() = 1 AND [OBJ].Filter([]::STGeomFromText('POLYGON((120.16606060606059714 -28.75999999999999446, 121.49818181818179141 -28.75999999999999446, 121.49818181818179141 -27.91999999999999815, 120.16606060606059714 -27.91999999999999815, 120.16606060606059714 -28.75999999999999446))',4326)) = 1
    By comparing to the SQL generated by 3.16 we can see that it is missing the fieldname immediately after SELECT and the geometry type in the filter statement:
    SELECT [POINTID],[OBJ] FROM [dbo].[POINTS] WHERE [OBJ].STIsValid() = 1 AND [OBJ].Filter([geography]::STGeomFrom [Create_QGIS_TEST.sql.txt](https://github.com/qgis/QGIS/files/7902614/Create_QGIS_TEST.sql.txt) Text('POLYGON((120.01937499999999659 -28.75999999999999446, 121.05812499999998977 -28.75999999999999446, 121.05812499999998977 -27.91999999999999815, 120.01937499999999659 -27.91999999999999815, 120.01937499999999659 -28.75999999999999446))',4326)) = 1

Note: The presence of a populated geometry_columns table in the database makes no difference.
QGIS_Crash.txt
Create_QGIS_TEST.txt

Versions

QGIS version
3.22.3-Białowieża
QGIS code revision
1628765
Qt version
5.15.2
Python version
3.9.5
GDAL/OGR version
3.4.1
PROJ version
8.2.1
EPSG Registry database version
v10.041 (2021-12-03)
GEOS version
3.10.0-CAPI-1.16.0
SQLite version
3.35.2
PDAL version
2.3.0
PostgreSQL client version
13.0
SpatiaLite version
5.0.1
QWT version
6.1.3
QScintilla2 version
2.11.5
OS version
Windows Server 2016 Version 1809
Active Python plugins
olivier
2.0
plugin_reloader
0.9.1
db_manager
0.1.20
grassprovider
2.12.99
MetaSearch
0.3.5
processing
2.12.99
sagaprovider
2.12.99

Supported QGIS version

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

New profile

  • I tried with a new QGIS profile

Additional context

SQL Server version is 2019, but setting the compatibility level back to earlier versions makes no difference.

Expanding the POINTS table in the browser causes QGIS to crash. Crash report attached but perhaps that should be a separate ticket.

@oacmose oacmose added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Jan 20, 2022
@gioman gioman added MS SQL data provider Regression Something which used to work, but doesn't anymore labels Jan 20, 2022
@nyalldawson nyalldawson self-assigned this Jan 21, 2022
@nyalldawson
Copy link
Collaborator

Related to case sensitive database setting

nyalldawson added a commit to nyalldawson/QGIS that referenced this issue Jan 21, 2022
…SCHEMA

tables, or queries will not run on case-sensitive databases

Fixes qgis#46907
qgis-bot pushed a commit that referenced this issue Jan 23, 2022
…SCHEMA

tables, or queries will not run on case-sensitive databases

Fixes #46907
nyalldawson added a commit that referenced this issue Jan 25, 2022
…SCHEMA

tables, or queries will not run on case-sensitive databases

Fixes #46907
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! MS SQL data provider Regression Something which used to work, but doesn't anymore
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants