pinchbv / floor

The typesafe, reactive, and lightweight SQLite abstraction for your Flutter applications
https://pinchbv.github.io/floor/
Apache License 2.0
947 stars 190 forks source link

How to update a List of an object as field of entity into table in Floor #805

Open ngminhkhoa opened 7 months ago

ngminhkhoa commented 7 months ago

I have below query to update and after I use cmd to generate file, I got error. I don't know why but I used this query in Room Database and it's ok

ERROR

The parameter newUsersJoined should be referenced like a list (x IN (:newUsersJoined)) Change the type of newUsersJoined to not be a List<> orreference it with IN (:newUsersJoined) (including the parentheses).


QUERY

@Query('UPDATE spaces_table '
      'SET '
      'ownedBy = :newOwnedBy, '
      'secondUserId = CASE WHEN :newSecondUserId IS NOT NULL THEN :newSecondUserId ELSE secondUserId END, '
      'avatar = :newAvatar, '
      'name = :newName,'
      'username = CASE WHEN :newUsername IS NOT NULL THEN :newUsername ELSE username END, '
      'type = :newType, '
      'isTurnOffNotification = :newIsTurnOffNotification, '
      'usersJoined = :newUsersJoined '
      'WHERE id = :spaceId')
  Future<int?> updateSpace(
    String spaceId,
    String newOwnedBy,
    String newSecondUserId,
    String newAvatar,
    String newName,
    String newUsername,
    String newType,
    int newIsTurnOffNotification,
    List<UserJoinedEntity> newUsersJoined,
  );