Skip to content

Commit

Permalink
Add hash method to datetime fieldtype (#77)
Browse files Browse the repository at this point in the history
* Add hash method to datetime fieldtype

(DIS-2036)
  • Loading branch information
Poeloe authored Jul 21, 2023
1 parent 549d118 commit d52f2b5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions flow/record/fieldtypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ def __repr__(self):
result = str(self)
return result

def __hash__(self):
return _dt.__hash__(self)


class varint(varint_type, FieldType):
def _pack(self):
Expand Down
4 changes: 4 additions & 0 deletions tests/test_fieldtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,10 @@ def test_datetime():
r = TestRecord(1521731723.123456)
assert r.ts == datetime.datetime(2018, 3, 22, 15, 15, 23, 123456)

r = TestRecord("2018-03-22T15:15:23.123456")
test = {r.ts: "Success"}
assert test[r.ts] == "Success"


@pytest.mark.parametrize(
"value,expected_dt",
Expand Down

0 comments on commit d52f2b5

Please sign in to comment.