Skip to content

Conversation

Chriztiaan
Copy link
Contributor

@Chriztiaan Chriztiaan commented Dec 4, 2024

Resolved an issue where .findMany (and other multiple row results) queries had a type of [][] instead of [].

When checking the db.watch(query, {onResult})'s onResult type:

before

find-many:

(results: {
    id: string | null;
    assets: {
        id: string | null;
        customer_id: string | null;
    }[];
}[][]) => void

find-first:

results: ({
    id: string | null;
    customer_id: string | null;
    customer: {
        ...;
    } | null;
} | undefined)[]) => void

After

find-many:

(results: {
    id: string | null;
    assets: {
        customer_id: string | null;
        id: string | null;
    }[];
}[]) => void

find-first:

(results: ({
    id: string | null;
    customer_id: string | null;
    customer: {
        ...;
    } | null;
} | undefined)[]) => void

Copy link

changeset-bot bot commented Dec 4, 2024

🦋 Changeset detected

Latest commit: 81e8837

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@powersync/drizzle-driver Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Chriztiaan Chriztiaan marked this pull request as ready for review December 9, 2024 07:17
@Chriztiaan Chriztiaan merged commit ed5bb49 into main Dec 10, 2024
7 checks passed
@Chriztiaan Chriztiaan deleted the fix/drizzle-watch-many-type branch December 10, 2024 08:13
@steveninety
Copy link

Hi, I think findFirst returning an array is (still) a mistake.

I've noticed that using a PowerSync Drizzle findFirst returns an object (which is correct and expected),
but wrapped inside toCompilableQuery, and also inside onResult as we can see above, a findFirst returns an array (always of length 1 though).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants