-
Notifications
You must be signed in to change notification settings - Fork 66
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
Support for UDT (hierarchyid, geometry and geography) #216
Conversation
tentone
commented
Aug 20, 2024
- Adds support for hierarchyid, geometry and geography SQL type.
- Currently a panic is thrown when the system tries to scan any UDT (user defined type)
- This has been brought up many times (e.g. 167, 79)
- Doesn't make sense to have a official driver that doesn't support all official SQL types.
- There are some forks such as this one to try to solve this issue and the solutions seems to work correctly for every case.
- I have tested the solution for all proposed types and have implemented a library to handle hierarchyid encoding and decoding in Go, that has been developed with the modified driver.
@microsoft-github-policy-service agree |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #216 +/- ##
==========================================
+ Coverage 74.79% 74.82% +0.03%
==========================================
Files 32 32
Lines 6379 6396 +17
==========================================
+ Hits 4771 4786 +15
- Misses 1325 1327 +2
Partials 283 283 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree the driver shouldn't panic and hierarchyid seems useful in non-CLR uses.
What are the non-CLR use cases for geometry values not converted to string?
case "geometry": | ||
return 2147483647, true | ||
default: | ||
panic(fmt.Sprintf("not implemented makeGoLangTypeLength for user defined type %s", ti.UdtInfo.TypeName)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we open an issue to implement app-supplied callbacks to decode unknown types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That could be a possible way to support other data types, but i think that these are the only ones that were missing from the driver, aside from really new types like the json type
Thank you! Geometry and geography are useful for example for spatial filtering. for example if you define the geometries for houses you can esily get wich house is at a location X, Y (by intersection) or for example get the closest house to a point etc. Geography and geometry are similar the main diference between them is that geometry is a more generic for any 2D in a generic X, Y referential and geography restricts its usage to earth coordinates taking account the earth curvature the hemispheres etc |
I meant - how does a Go app consume the binary values? AFAIK those are serialized CLR objects. Maybe I've misunderstood that. |
Yes i belive so, there are at leat two libs to support serialization of these in go go-mssqlclrgeo and go-geom |