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 provider fails to load UNIQUEIDENTIFIER fields #25284

Closed
qgib opened this issue Nov 2, 2017 · 4 comments
Closed

MSSQL provider fails to load UNIQUEIDENTIFIER fields #25284

qgib opened this issue Nov 2, 2017 · 4 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers

Comments

@qgib
Copy link
Contributor

qgib commented Nov 2, 2017

Author Name: Kristian Thy (@kthy)
Original Redmine Issue: 17387
Affected QGIS version: master
Redmine category:data_provider/mssql


Experienced in QGIS 2.18.12, 2.18.14 on Windows 8.1. (Code still present in master branch, but 2.99 crashes before I reach it, apparently due to an unrelated issue.)

I'm trying to load a layer from MSSQL into PostgreSQL using the DB Manager plugin (following the recipe at https://gis.stackexchange.com/a/200594/10741) but I receive this error for each row:

Error 7
Feature write errors:
Creation error for features from #0 to #0. Provider errors was: 
PostGIS error while adding features: ERROR:  value too long for type character varying(16)

Source code investigation leads me to believe that this is caused by the MSSQL provider treating the @UNIQUEIDENTIFIER@ datatype as a @QVariant::String@. Problem is that MSSQL reports the length of this datatype as 16, which is the byte size of a GUID. When converted to a string, the length is actually 36 characters, so the error I'm seeing is likely caused by trying to cram a 36 character string into a field 16 characters wide.

Luckily, MSSQL reports the size of the datatype in the precision field also returned by @exec sp_columns@. My hunch is that the issue can thus be resolved by the attached patch to @src/providers/mssql/qgsmssqlprovider.cpp@. Unfortunately I can't build QGIS on Windows myself, so I have not tested the patch.


@qgib
Copy link
Contributor Author

qgib commented Nov 2, 2017

Author Name: Giovanni Manghi (@gioman)


Better submit the patch as a pull request on github, otherwise here it won't be noticed/reviewed.


  • status_id was changed from Open to Feedback

@qgib
Copy link
Contributor Author

qgib commented Nov 2, 2017

Author Name: Kristian Thy (@kthy)


Giovanni Manghi wrote:

Better submit the patch as a pull request on github, otherwise here it won't be noticed/reviewed.

Will do later tonight.

@qgib
Copy link
Contributor Author

qgib commented Nov 3, 2017

Author Name: Kristian Thy (@kthy)


Submitted as PR 5521.

#5521


  • status_id was changed from Feedback to Open

@qgib
Copy link
Contributor Author

qgib commented Nov 13, 2017

Author Name: Kristian Thy (@kthy)


Applied in changeset 320bda0.


  • done_ratio was changed from 0 to 100
  • status_id was changed from Open to Closed

@qgib qgib closed this as completed Nov 13, 2017
@qgib qgib added Bug Either a bug report, or a bug fix. Let's hope for the latter! Data Provider Related to specific vector, raster or mesh data providers labels May 25, 2019
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! Data Provider Related to specific vector, raster or mesh data providers
Projects
None yet
Development

No branches or pull requests

1 participant