Skip to content

Issues with DateTime ISO fields #29

@JasperCheung

Description

@JasperCheung

when i run gql_run and the renderer_dataclasses.py encounters a DateTime field it generates a field:

var_name: datetime = None

when I run a query that returns a datetime object I get the following error:

File "/Users/jasper/Documents/test/test-graph-python-client/env/lib/python3.7/site-packages/dataclasses_json/core.py", line 220, in _decode_generic
    res = _get_type_cons(type_)(xs)
  File "/Users/jasper/Documents/test/test-graph-python-client/env/lib/python3.7/site-packages/dataclasses_json/core.py", line 260, in <genexpr>
    for x in xs)
  File "/Users/jasper/Documents/test/test-graph-python-client/env/lib/python3.7/site-packages/dataclasses_json/core.py", line 165, in _decode_dataclass
    infer_missing)
  File "/Users/jasper/Documents/test/test-graph-python-client/env/lib/python3.7/site-packages/dataclasses_json/core.py", line 179, in _decode_dataclass
    dt = datetime.fromtimestamp(field_value, tz=tz)
TypeError: an integer is required (got type str)

I think this is because in:

if field.type == 'DateTime':
suffix = '= DATETIME_FIELD'
field_type = 'datetime'
if field.nullable:
suffix = f'= {field.default_value}'
buffer.write(f'{field.name}: {field_type} {suffix}')

suffix is being overwritten if the field is nullable and DATETIME_FIELD isn't being used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions