Skip to content

bug(postgrest): Where() with ternary drops the condition #415

Description

@fresh55

Found this while deleting expired records. the IsProtected check is lost and protected rows get deleted too:

await client.Table<Record>().Where(x => x.IsProtected ? false : x.IsExpired).Delete();
// sends is_expired=eq.True

same query with x => !x.IsProtected && x.IsExpired sends and=(is_protected.not.eq.True,is_expired.eq.True) which is correct.

other ternaries have the same problem, the last bool column wins:

.Where(x => x.IsProtected ? x.IsExpired : false)        // sends is_expired=eq.True
.Where(x => x.IsProtected ? x.IsExpired : x.IsArchived) // sends is_archived=eq.True

there is no VisitConditional in WhereExpressionVisitor, so VisitMember just overwrites the filter for every branch. no error, the request goes out with half the filter.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions