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

[mssql] Allow SQL queries as layer sources #60728

Merged
merged 9 commits into from
Feb 25, 2025

Conversation

nyalldawson
Copy link
Collaborator

@nyalldawson nyalldawson commented Feb 24, 2025

Allows loading SQL Server queries as map layers from the browser, and updating the SQL for existing query layers

Sponsored by City of Canning

Fixes #19301

@nyalldawson nyalldawson added Feature Changelog Items that are queued to appear in the visual changelog - remove after harvesting MS SQL data provider labels Feb 24, 2025
@qgis-bot
Copy link
Collaborator

@nyalldawson

This pull request has been tagged for the changelog.

  • The description will be harvested so please provide a "nearly-ready" text for the final changelog
  • If possible, add a nice illustration of the feature. Only the first one in the description will be harvested (GIF accepted as well)
  • If you can, it's better to give credits to your sponsor, see below for different formats.

You can edit the description.

Format available for credits
  • Funded by NAME
  • Funded by URL
  • Funded by NAME URL
  • Sponsored by NAME
  • Sponsored by URL
  • Sponsored by NAME URL

Thank you!

@github-actions github-actions bot added this to the 3.44.0 milestone Feb 24, 2025
Copy link

github-actions bot commented Feb 24, 2025

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit 749c2c5)

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 749c2c5)

@nyalldawson
Copy link
Collaborator Author

@alexbruy this one needs #60680 -- does your approval extend to that?

Follows the approach used by eg the postgres provider, where a mssql
layer can specify an arbitrary SQL query to use as the layer's
source instead of a table.

This is done by using the URI form:

   table="(SELECT ...)" key='primary_key' srid=4326 type=POINT

The query MUST be wrapped in (), and the primary key and geometry
properties MUST be set in the URI.

Note that SQL Server requirements mandate that EVERY column in the query
must have an explicit name/alias set, or the database queries will
fail.

Sponsored by City of Canning
Allows loading SQL Server queries as map layers from the browser,
and updating the SQL for existing query layers

Sponsored by City of Canning
@nyalldawson nyalldawson merged commit 23ca9df into qgis:master Feb 25, 2025
32 checks passed
@nyalldawson nyalldawson deleted the sql_query branch February 25, 2025 00:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog Items that are queued to appear in the visual changelog - remove after harvesting Feature MS SQL data provider
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use SELECT query as data source in MSSQL
3 participants