Coder Social home page Coder Social logo

Geometry column type support about tds HOT 8 OPEN

mjaric avatar mjaric commented on August 16, 2024
Geometry column type support

from tds.

Comments (8)

mjaric avatar mjaric commented on August 16, 2024 1

Then you will be covered 😄. I will definitely try to figure out workaround for arm issue anyways and make instructions in readme

from tds.

fnicastri avatar fnicastri commented on August 16, 2024

For now my workaround is to exclude the real field from the schema and using a virtual field filled with a fragment in the query:

query =
      from p in Project,
        select_merge: %{location: fragment("CAST(Location AS nvarchar(100))")}

    Repo.one!(query)

or

query =
      from p in Project,
        select_merge: %{location: fragment("Location.STAsText()")}

    Repo.one!(query)

from tds.

mjaric avatar mjaric commented on August 16, 2024

The more I look at it, the more I think it should be just ecto custom type.
Do we need structs or string is good enough?

from tds.

fnicastri avatar fnicastri commented on August 16, 2024

I think the first step should be to make TDS aware of the types so it will not error.
If you query directly the db with t-sql it return an Hex.
As far as I understand, I'm not a SQLServer expert, you use the included functions to decode them, as I did with the fragment, unless you are in c# land, then they are 'native'.

Ideally we would have all the types already decoded, maybe in WKT or WKB, to manipulate the values with the appropriate libraries.

Microsoft SQL Server CLR Types Serialization Formats

from tds.

fnicastri avatar fnicastri commented on August 16, 2024

Hi @mjaric @josevalim

I'm facing another limitation now, I moved all containers on my M1 Mac so I have to use the azure-sql-edge docker image.
azure-sql-edge is not complete and can't use the CLR functions like .STAsText() or cast to nvarchar, therefore the fragment doesn't work anymore.

This will not impact the production system but is not ideal from a dev POV, do you think we can at least find a way to get the binary value from the geography/geometry column?
To not crash Ecto during the queries.

from tds.

mjaric avatar mjaric commented on August 16, 2024

We are trying to make plan for binary format support, that should resolve STAsString issue, but if that is the case, Im not sure if you will be able to use other geometry::* functions.

Did you try to run other sqlerver image in amd64 emulated mode?

from tds.

fnicastri avatar fnicastri commented on August 16, 2024

We are trying to make plan for binary format support, that should resolve STAsString issue,

This is awesome!

but if that is the case, Im not sure if you will be able to use other geometry::* functions.

Why? You mean with the arm version?

I'm less than worried to no be able to use the geometry functions, I don't really need to query the database with geo* functions.
I need just the values of the geometries in WKT/WKB or in another standard format.
I can even try to decode them myself with a bit of help if I can get the binary.
We just have POINTs in that field, it should not be complex, right?

What I need is to extract some POINTs from this legacy DB to interact with the data in another new system.

The legacy system will go under a total rewrite anyway later this year and we will use Postgres.

Did you try to run other sqlserver image in amd64 emulated mode?

No, for now I tried just the arm one and disabled the problematic field,
I read this is a bit problematic under Monterey.

from tds.

fnicastri avatar fnicastri commented on August 16, 2024

@mjaric
Any progress on this?

The big rewrite got postponed so we are stuck with the legacy database,
meanwhile we are porting smaller pieces of our system to elixir and we need to
access one of the geography columns.

We can do it converting the geometry during the query with STAsText()
but I would like to explore the decoding of the geography data on the Elixir side.

Can you help me to get the raw binary from the database?

I'm hitting Unsupported Token code 0x3 in Token Stream

from tds.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.