evaluate behavior of adding a tuple_() as a column to select(), Query(). coerce? behavior changes on master?
See original GitHub issueIssue
When trying to select a tuple_
:
class User(base):
__tablename__ = "users"
uid = Column(Integer, primary_key=True)
username = Column(String)
[...]
q = session.query(User).add_columns(sqlalchemy.tuple_(User.uid, User.username))
print(q.all())
The returned value for the tuple is a string, which is hardly exploitable:
[(<__main__.User object at 0x7fa37c9fce48>, '(1,foo)')]
One requires, I think, with a postgresql backend to test this.
Expected behavior
I would expect to receive a Python tuple [(<__main__.User object at 0x7fa37c9fce48>, (1, 'foo'))]
as a result.
Versions
Flask-SQLAlchemy==2.4.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (9 by maintainers)
Top Results From Across the Web
Functions for Working with Tuples | ClickHouse Docs
A function that allows getting a column from a tuple. ... Example of using a Tuple -type column as the untuple function parameter:...
Read more >SQL Order by Clause overview and examples
This article will cover the SQL ORDER BY clause including syntax, usage scenarios to sort out results in a Select statement.
Read more >psycopg2.extras – Miscellaneous goodies for Psycopg 2
New in version 2.3. ... A cursor that generates results as namedtuple . fetch*() methods will return named tuples instead of regular tuples,...
Read more >Spark SQL, DataFrames and Datasets Guide
A DataFrame is a Dataset organized into named columns. It is conceptually equivalent to a table in a relational database or a data...
Read more >The Craziness of Subset Selection in pandas — an Edge Case
Oddly enough, tuples are allowable as valid column names in a pandas DataFrame. The KeyError informs us that the tuple (1, 2) is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
this should work on 1.3.x and 1.2.x:
since no backend other than PostgreSQL actually allows the syntax of “SELECT (x, y, z) FROM table”, I’ve opted to go with a compile-level raise when the tuple is detected as being placed in the top-most columns clause of the statement. the Bundle implies a non-tuple series of columns in the SELECT that become a sub-row. It’s different and it would be best if, given a tuple_() in the select(), we refuse the temptation to guess.