Menu

#48 Bug - QueryableDatatype.equals() always returns true if operators null

1.0
closed
None
2015-04-15
2015-04-15
Malcolm
No

QueryableDatatype.equals() is implemented based on the operator alone: if the operator in both objects is null, it returns true. It should compare the literalValue if operator is null.

DBInteger int1 = new DBInteger().
DBInteger int2 = new DBInteger().
int1.setValue(100);
int2.setValue(101);

int1.operator = a DBEqualsOperator
int1.operator.firstValue = a separate DBInteger with operator=null, and literalValue=(Long)100.
int2.operator = a separate DBEqualsOperator
int2.operator.firstValue = a separate DBInteger with operator=null, and literalValue=(Long)101.

When executing int1.equals(int2), this calls QueryableDatatype.equals(),
which calls equals() on the two DBEqualsOperators.
That in turn calls equals() on the two inner DBIntegers.
They both have operator=null, so returns true.
Instead, it should have compared the literalValues.

Not sure what should happen when one has operator and the other has only a literalValue.

Unit test nz.co.gregs.dbvolution.datatypes.DBIntegerTest.notEqualGivenDifferentLiteralValues() will reveal this.

Note: this bug will only become apparent once https://sourceforge.net/p/dbvolution/tickets/47 is resolved.

Discussion

  • Malcolm

    Malcolm - 2015-04-15
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -18,4 +18,6 @@
    
     Not sure what should happen when one has operator and the other has only a literalValue.
    
    +Unit test nz.co.gregs.dbvolution.datatypes.DBIntegerTest.notEqualGivenDifferentLiteralValues() will reveal this.
    +
     Note: this bug will only become apparent once https://sourceforge.net/p/dbvolution/tickets/47 is resolved.
    
     
  • Gregory Graham

    Gregory Graham - 2015-04-15
    • status: open --> accepted
     
  • Gregory Graham

    Gregory Graham - 2015-04-15

    Improved equals methods

     
  • Gregory Graham

    Gregory Graham - 2015-04-15
    • status: accepted --> closed
     

Anonymous
Anonymous

Add attachments
Cancel