You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixing the db.session.execute(stmt).scalars().all() problem.
This was part of the move to SQLAlchemy 2.0, and it could be very problematic. scalars() gets a single value from a row, while all() gets all the rows and puts them into a list. So this makes a list of single values. Which is fine, if and only if we only want a single value from the row. But if you want all the columns that are loaded (like from a invited user model), this breaks a lot of things, and has unknown results.
We need to go through all uses of this pattern in the API code and verify - are we wanting just a single column's data to be returned, or multiple columns of data returned. If multiple columns of data, then we need to remove the .scalars() part of that code.
We might need to verify all other uses of .scalars() or .scalar() beyond those that use .all() too.
The text was updated successfully, but these errors were encountered:
Fixing the
db.session.execute(stmt).scalars().all()
problem.This was part of the move to SQLAlchemy 2.0, and it could be very problematic. scalars() gets a single value from a row, while all() gets all the rows and puts them into a list. So this makes a list of single values. Which is fine, if and only if we only want a single value from the row. But if you want all the columns that are loaded (like from a invited user model), this breaks a lot of things, and has unknown results.
We need to go through all uses of this pattern in the API code and verify - are we wanting just a single column's data to be returned, or multiple columns of data returned. If multiple columns of data, then we need to remove the
.scalars()
part of that code.We might need to verify all other uses of
.scalars()
or.scalar()
beyond those that use.all()
too.The text was updated successfully, but these errors were encountered: