edgedb / edgedb-go

The official Go client library for EdgeDB
https://pkg.go.dev/github.com/edgedb/edgedb-go
Apache License 2.0
167 stars 11 forks source link

Can't decode datetime into `edgedb.OptionalDateTime` #281

Closed fmoor closed 9 months ago

fmoor commented 9 months ago

originally reported on discord

Reproduction

abstract type Content {
    required property created -> datetime {
        default := datetime_of_statement();
        readonly := true;
    };
    required property updated -> datetime {
        default := datetime_of_statement();
    };
    required link creator -> User;
    link deletion -> DeletionEvent;
}
type ConcreteContent struct {
// bunch of other fields
    ID             edgedb.UUID           `edgedb:"id"`
    Created        edgedb.OptionalDateTime `edgedb:"created"`
    Updated        edgedb.OptionalDateTime `edgedb:"updated"`
// followed by more fields
}
id, _ := edgedb.ParseUUID(incoming.ID)
concreteInstance := Concrete{ID: id}
query := `select Concrete {
       otherConcreteType: {
        id,
        title,
        updated
       },
    } filter .id = <uuid>$0`
err := s.Conn.QuerySingle(ctx, query, &concreteInstance, concreteInstance.ID)
if err != nil {
    return OtherConcreteType{}, err
}
otherConcreteInstance := concreteInstance.otherConcreteType
return otherConcreteInstance, nil

Actual behavior edgedb.OptionalDateTime values are not set.

Expected behavior edgedb.OptionalDateTime should handle non optional values.

fmoor commented 9 months ago

I wasn't able to reproduce this. I asked for a minimal reproduction from the user reporting the issue on discord.

TomLisankie commented 9 months ago

Hi, I'm the user who reported it. The issue ended up being with my query. This issue can be closed. Thanks for your help.

fmoor commented 9 months ago

Sounds good. Thanks @TomLisankie!