Comments (4)
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.
@touchedthecode Thanks for submitting the issue!
I believe, we shouldn't convert all results to tuples by default, because:
- As mentioned above, somebody might indeed want to use the module specific types
- It can introduce backwards incompatibility if somebody is already using module specific types
- 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.
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.
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)
- Keyword "table must exist" fails with DB's which don't support information_schema
- Improve error messages in assertion keywords
- Recover docs from original Franz-see project
- v.1.30 - connection issue using MS SQL + pyodbc + SQL Driver HOT 1
- [feature] enhance Execute script KW to support more statement blocks HOT 6
- New Oracledb driver - support switching to thick mode and back to thin mode HOT 3
- Extend compare methods with pandas support HOT 2
- Self managed connections HOT 5
- Use Python convention naming
- [New client] Impala client
- [New client] Databricks client
- Handling multiple database connections HOT 5
- ProgrammingError: Unsupported parameter (Support for dict only): [] HOT 6
- Execute Sql String error with characters % HOT 6
- Parse SQL script files using external lib
- Single "Row Count" keyword with Assertion Engine HOT 1
- Smart wait for "check if exists" / "row count" assertion keywords
- Query params don't work for MS SQL (pymssql) HOT 1
- Call stored procedure does not work with pymssql driver HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from robotframework-database-library.