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
{{ message }}
Repository navigation
updateWhere fails to deserialize returned rows when a field uses a column= override #5911
When a table model has a field with a column= override, Model.db.updateWhere(...) throws after the UPDATE has run. The returned rows are keyed by database column name (auth_user_id), but the generated fromJson reads the field name (authUserId). That field comes back null and deserialization fails.
Cause: insert and update build their returning list with buildReturningClause() (sql_query_builder.dart), which renames mapped columns to their field names when table.hasColumnMapping is true. updateWhere (database_connection.dart:494, and :486–487 with limit/orderBy) and updateById (:403) use a plain RETURNING * instead. I reproduced updateWhere; updateById has the same code and should fail the same way.
Passing noReturn: true to updateWhere avoids it, because no rows are deserialized. updateById has no such option.
type 'Null' is not a subtype of type 'String' in type cast
package:serverpod_serialization/src/extensions/serialization_extensions.dart 61:43 UuidValueJsonExtension.fromJson
package:<project>/src/generated/.../account.dart new Account.fromJson
package:<project>/src/generated/protocol.dart Protocol.deserialize
package:serverpod_database/src/adapters/postgres/database_connection.dart 503:72 PostgresDatabaseConnection.updateWhere
The UPDATE has already been applied when the exception is thrown. Outside a transaction, the row is changed but the call reports failure.
Expected behavior
updateWhere and updateById return the updated rows, using buildReturningClause(table) for their RETURNING list like insert and update do.
Activity