Skip to content

Commit

Permalink
Fix primary type detection if ancestors exist
Browse files Browse the repository at this point in the history
  • Loading branch information
nsidnev committed Nov 2, 2023
1 parent f48673f commit 1dd4e63
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
25 changes: 25 additions & 0 deletions internal/client/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7806,3 +7806,28 @@ func TestSendAndReceiveRangeLocalDate(t *testing.T) {
})
}
}

func TestCustomSequenceTypeHandling(t *testing.T) {
ddl := `
CREATE SCALAR TYPE SampleSequence extending std::sequence;
CREATE TYPE Sample { CREATE PROPERTY val -> SampleSequence; };
`
inRolledBackTx(t, ddl, func(ctx context.Context, tx *Tx) {
var result struct {
Val types.OptionalInt64 `edgedb:"val"`
}

// Decode value
err := tx.QuerySingle(ctx, `
with inserted_sample := (insert Sample{})
select inserted_sample { val }
`,
&result,
)
assert.NoError(t, err)

val, isSet := result.Val.Get()
assert.Equal(t, int64(1), val)
assert.True(t, isSet)
})
}
2 changes: 1 addition & 1 deletion internal/codecs/codecs.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func GetScalarDescriptorV2(
desc *descriptor.V2,
) *descriptor.V2 {
if len(desc.Ancestors) > 0 {
desc = &desc.Ancestors[0].Desc
return &desc.Ancestors[len(desc.Ancestors)-1].Desc
}

return desc
Expand Down

0 comments on commit 1dd4e63

Please sign in to comment.