Skip to content

Matching is broken in 1.35 for any model with a primary key #1263

@monktastic

Description

@monktastic

In this commit, I believe

        const compositeIndex =
          current.model.uniqueIndexes.map((index) => index.name).includes(child) ||
          current.model.primaryKey?.name === child ||
          current.model.primaryKey?.fields.join('_');

should be

        const compositeIndex =
          current.model.uniqueIndexes.map((index) => index.name).includes(child) ||
          current.model.primaryKey?.name === child ||
          current.model.primaryKey?.fields.join('_') === child;

or similar. As an aside, I don't understand how the next line is supposed to work:

        if (compositeIndex) {
          return matchMultiple(item, where[child] as FindWhereArgs, current, delegates);
        }

because by pulling out child from where (which we now know is a key/index), you lose the actual key, and I think the contents won't match any of the field names. That's probably just me not understanding how this is supposed to work in general, but thought I'd point it out just in case.

@carterbush

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions