Giter VIP home page Giter VIP logo

Comments (4)

bhirsz avatar bhirsz commented on September 17, 2024 1

If there is no returnAsDict specified, DatabaseLibrary will return whatever given database module is returning by default. According to https://peps.python.org/pep-0249/ module implementing DB API 2.0 should return list of tuples - but I guess some of the modules (like pyodbc) are more liberal and return list of objects like pyodb.Row.

We have two solutions here:

a) either forcefully convert output to tuples (which will fix issues like yours but may cause other issues if the objects can't be converted to Tuple or someone rely on module specific return type)
b) or fix the docs to mention exact behaviour (something along .. to query for the values that will be returned. Type of the values depends on the database module used but it should be tuple-like. - but I'm bad at writing docs ;) )

I'm leaning forward b)

from robotframework-database-library.

amochin avatar amochin commented on September 17, 2024

@touchedthecode Thanks for submitting the issue!

I believe, we shouldn't convert all results to tuples by default, because:

  1. As mentioned above, somebody might indeed want to use the module specific types
  2. It can introduce backwards incompatibility if somebody is already using module specific types
  3. We'd dive into a rabbit hole of one more custom handling of DB behavior

We definitely should updated the docs, as you mentioned above in b)

From the other side, I can see the issue when using the comparisons like Lists should be equal.
@bhirsz what do you think about introducing an optional parameter force_return_tuples (default would be False) in the Query keyword - and do explicit converting to tuples if requested?

from robotframework-database-library.

bhirsz avatar bhirsz commented on September 17, 2024

We can introduce it, though if someone needs converting the type there is returnAsDict already. Would having two types of converters for output be okay? It still would need to be explicit configured

from robotframework-database-library.

amochin avatar amochin commented on September 17, 2024

You're right, with a new parameter you'd need to set the conversion explicitly anyway - and for this case the returnAsDict is already enough.
Good, then we'll just update the docs here.

from robotframework-database-library.

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.