Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-527

Custom Gt/Gte/Lt/Lte filter builders for unsigned integer fields represented using signed integers

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Critical - P2 Critical - P2
    • 2.4
    • Affects Version/s: 1.5
    • Component/s: None
    • Labels:
      None
    • Environment:
      All

      The new typed query builder in 1.5 does not correctly convert queries when dealing with signed <-> unsigned conversions and GTE, LTE, GT, LT operations. Consider:

      class Foo
      {
      [BsonElement("bar")]
      [BsonRepresentation(BsonType.Int32, AllowOverflow = true)]
      public uint Bar

      { get; set; }

      }

      Query<Foo>.GTE(f => f.Bar, (uint)int.MaxValue + 1) // Error, needs to execute $lt : 0, but instead executes $gte : -2147483648, which is always true

      Marked this critical because while folks can work around this, it is counter intuitive and assuming the bug is fixed properly, will cause breaking changes that silently lead to corruption or undefined state for anyone that starts using these APIs like this.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            optimiz3 Alexander Nagy
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: