Skip to content

Commit

Permalink
add SqlQuery options. (#17)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #17

X-link: facebook/hhvm#9396

Adds basic operator functions for implementing hash function for QueryOptions.

Reviewed By: aditya-jalan

Differential Revision: D48757065

fbshipit-source-id: a12a27125ba8a1ee7c8468e43bcd2f3a3731b88e
  • Loading branch information
Cihangir Savas authored and facebook-github-bot committed Sep 21, 2023
1 parent f0d6d6e commit a994fd2
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions squangle/mysql_client/Query.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ class QueryOptions {
return attributes_;
}

bool operator==(const QueryOptions& other) const {
return attributes_ == other.attributes_;
}

std::size_t hashValue() const {
return folly::hash::commutative_hash_combine_range(
attributes_.begin(), attributes_.end());
}

protected:
QueryAttributes attributes_;
};
Expand Down Expand Up @@ -610,4 +619,14 @@ inline std::ostream& operator<<(
}
} // namespace std

namespace std {
template <>
struct hash<facebook::common::mysql_client::QueryOptions> {
std::size_t operator()(
const facebook::common::mysql_client::QueryOptions& opt) const {
return opt.hashValue();
}
};
} // namespace std

#endif // COMMON_ASYNC_MYSQL_QUERY_H

0 comments on commit a994fd2

Please sign in to comment.