Skip to content

Multiple Joins "Invalid join condition" #474

@lautarodapin

Description

@lautarodapin

Stackblitz

https://stackblitz.com/edit/vitejs-vite-gnkg2sdh?file=src%2FApp.tsx

I'm having this issue when i'm trying to
This are my collections nothing fancy

    const playersCollection = createCollection(
        queryCollectionOptions({
            queryKey: ["jugadores", clubId],
            queryFn: async () => {
                const results = await call.get<FrappeResponse<Jugador[], { count: number }>>(
                    "setplus.setplus.doctype.jugador.jugador.get_filtered_jugadores",
                    {
                        club: clubId,

                        page_size: 9999999,
                        page: 0,
                    },
                );
                return results.message.data ?? [];
            },
            getKey: (item) => item.name,
            queryClient,
        }),
    );
    const clientsCollection = createCollection(
        queryCollectionOptions({
            queryClient,
            queryKey: ["clientes", clubId],
            queryFn: async () => {
                return await db.getDocList<Cliente>("Cliente", {
                    filters: [["club", "=", clubId]],
                    fields: ["*"],
                    limit: 9999999,
                });
            },
            getKey: (item) => item.name,
        }),
    );
    const balancesCollection = createCollection(
        queryCollectionOptions({
            queryClient,
            queryKey: ["balances", clubId],
            queryFn: async () => {
                return await db.getDocList<BalanceClientePorClub>("Balance Cliente por Club", {
                    filters: [["club", "=", clubId]],
                    fields: ["*"],
                    limit: 9999999,
                });
            },
            getKey: (item) => item.name,
        }),
    );

    const { data } = useLiveQuery((q) =>
        q
            .from({ player: playersCollection })
            .join({ client: clientsCollection }, ({ client, player }) => eq(client.player, player.name))
            .join({ balance: balancesCollection }, ({ balance, client }) => eq(balance.client, client.name))
            .select(({ player, client, balance }) => ({
                player,
                client,
                balance,
            })),
    );

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