Skip to content

react-db@0.1.78 electric createLiveQueryCollection inconsistent data without getKey #1423

Description

@boyswan
  • [x ] I've validated the bug against the latest version of DB packages

Describe the bug

When using the latest react-db@0.1.78, createLiveQueryCollection with an electric collection returns inconsistent data. In my case, it returns 1/n items. On 0.1.77 it returns the full set.

const teamsWithUserCollection = createLiveQueryCollection({
  getKey: i => i.team.id,   //  <------ this is now required to fetch all data correctly
  query: (q) =>
    q
      .from({ team: teamCollection })
      .join({ user: userCollection }, ({ user, team }) => eq(user.id, team.user_id))
      .select(({ team, user }) => ({
        team: team,
        profile: user?.profile,
      }))
})

export const useTeams = () => {
  const { data, isLoading } = useLiveQuery(
    (q) => {
      return q.from({ teamWithUser: teamsWithUserCollection })
    }
     ...
  )

Adding getKey fixed the issue.

Additional context

Testing all latest packages, but previous react-db@0.1.77 works without getKey

"@tanstack/db": 0.6.0
"@tanstack/electric-db-collection": 0.2.42
# "@tanstack/react-db": 0.1.78
"@tanstack/react-db": 0.1.77

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions