Skip to content

Commit

Permalink
Reflecting krapie's comment Changing mismatched code conventions and …
Browse files Browse the repository at this point in the history
…rollback to String "null"
  • Loading branch information
fourjae committed Sep 28, 2023
1 parent 7aad26d commit b5f4740
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
3 changes: 1 addition & 2 deletions pkg/document/crdt/primitive.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ func (p *Primitive) Bytes() []byte {
func (p *Primitive) Marshal() string {
switch p.valueType {
case Null:
return ""
return "null"
case Boolean:
return fmt.Sprintf("%t", p.value)
case Integer:
Expand All @@ -213,7 +213,6 @@ func (p *Primitive) Marshal() string {
return fmt.Sprintf(`"%s"`, p.value)
case Date:
return fmt.Sprintf(`"%s"`, p.value.(gotime.Time).Format(gotime.RFC3339))
// when Null or default
default:
return ""
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/document/crdt/primitive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestPrimitive(t *testing.T) {
valueType crdt.ValueType
marshal string
}{
{nil, crdt.Null, ""},
{nil, crdt.Null, "null"},
{false, crdt.Boolean, "false"},
{true, crdt.Boolean, "true"},
{0, crdt.Integer, "0"},
Expand Down
1 change: 1 addition & 0 deletions pkg/document/json/array.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ func (p *Array) addInternal(
) crdt.Element {
return p.insertAfterInternal(p.Array.LastCreatedAt(), creator)
}

func (p *Array) insertAfterInternal(
prevCreatedAt *time.Ticket,
creator func(ticket *time.Ticket) crdt.Element,
Expand Down
4 changes: 4 additions & 0 deletions pkg/document/json/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func (p *Object) SetNull(k string) *Object {
}
return primitive
})

return p
}

Expand All @@ -142,6 +143,7 @@ func (p *Object) SetBool(k string, v bool) *Object {
}
return primitive
})

return p
}

Expand All @@ -154,6 +156,7 @@ func (p *Object) SetInteger(k string, v int) *Object {
}
return primitive
})

return p
}

Expand All @@ -179,6 +182,7 @@ func (p *Object) SetDouble(k string, v float64) *Object {
}
return primitive
})

return p
}

Expand Down

0 comments on commit b5f4740

Please sign in to comment.