Skip to content

Commit d7c96b8

Browse files
committed
Add a comment explaining why gh_id needs a > 0 condition here
This is weird and not a great example and we should have a comment here explaining why :)
1 parent 3a9b31d commit d7c96b8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/user/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ impl<'a> NewUser<'a> {
8383
gh_access_token: self.gh_access_token.clone(),
8484
};
8585

86+
// We need the `WHERE gh_id > 0` condition here because `gh_id` set
87+
// to `-1` indicates that we were unable to find a GitHub ID for
88+
// the associated GitHub login at the time that we backfilled
89+
// GitHub IDs. Therefore, there are multiple records in production
90+
// that have a `gh_id` of `-1` so we need to exclude those when
91+
// considering uniqueness of `gh_id` values. The `> 0` condition isn't
92+
// necessary for most fields in the database to be used as a conflict
93+
// target :)
8694
let conflict_target = sql::<Integer>("(gh_id) WHERE gh_id > 0");
8795
insert(&self.on_conflict(
8896
conflict_target,

0 commit comments

Comments
 (0)