Git Product home page Git Product logo

Comments (7)

TimelordUK avatar TimelordUK commented on June 22, 2024

I have added this test to the params test suite and this now passes on my system. May need some more work to this, currently the driver looks for variant type and reads the corresponding col type attribute and binds to that type. Let me know if it fails other types. Update to test.

from node-sqlserver-v8.

patriksimek avatar patriksimek commented on June 22, 2024

Thanks, it's working now, but noticed this in my tests.

select cast(11.77 as sql_variant) as variant

Value is casted varchar, should be number.

from node-sqlserver-v8.

TimelordUK avatar TimelordUK commented on June 22, 2024

yes. it looks like again the driver then will either have to guess or/and maybe a hint could be passed in similar to previous discussion. i.e.

conn1.query("select cast(11 as sql_variant) as data;", [sql.Double()], function (err, res) {
// driver will ask to bind variant to hint type ..... or it will have to guess
}

I will need to look to see if a declared type is given, this conversion would work OK.

from node-sqlserver-v8.

patriksimek avatar patriksimek commented on June 22, 2024

According to this docs, variant contains type information (basetype). Not sure how it is with ODBC.

from node-sqlserver-v8.

TimelordUK avatar TimelordUK commented on June 22, 2024

OK, I think I finally understand what is going on here ... I am testing a fix at the moment but do not want to release until i am confident. It will fall back to char if it cannot read the variant header to a known type - however if it can read type it will automatically translate.

hopefully in a day or so I will release this.

from node-sqlserver-v8.

TimelordUK avatar TimelordUK commented on June 22, 2024

I have checked the fix into latest version ... it handles basic types OK I have added some tests, so example above should decode correctly to number.

from node-sqlserver-v8.

TimelordUK avatar TimelordUK commented on June 22, 2024

I will assume the issue now closed. Thanks for bringing this and all other very good tests to my attention. Any more issues with variant please raise a new issue.

from node-sqlserver-v8.

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.