Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix equalNullSafe comparison
  • Loading branch information
Vinod K C committed Jun 26, 2015
commit f2d0b53ebd0930f30f05fda2b00c9c0e835b3b79
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,7 @@ case class CaseKeyWhen(key: Expression, branches: Seq[Expression]) extends CaseW
}

private def equalNullSafe(l: Any, r: Any) = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should at least consider renaming this function. Null safe equals in sql typically returns true for null <=> null

http://dev.mysql.com/doc/refman/5.0/en/comparison-operators.html#operator_equal-to

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marmbrus
Shall I rename the function private def equalNullSafe(l: Any, r: Any)
to private def equal(l: Any, r: Any) ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or threeValueEquals ?

if (l == null && r == null) {
true
} else if (l == null || r == null) {
if (l == null || r == null) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is far enough from Java/Scala semantics that it warrants a scaladoc and a pointer to NULL semantics in SQL, IMO

false
} else {
l == r
Expand Down