Skip to content

Commit 7f326df

Browse files
committed
keep the metadata and links for the merged-in document body if the merged-into document body has no metadata or links.
1 parent b9cb23d commit 7f326df

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Sources/JSONAPI/Document/Document.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,11 @@ extension Document.Body.Data where PrimaryResourceBody: ResourceBodyAppendable {
272272
}
273273

274274
extension Document.Body.Data where PrimaryResourceBody: ResourceBodyAppendable, MetaType == NoMetadata, LinksType == NoLinks {
275-
public func merging<OtherMeta, OtherLinks, OtherDescription, OtherError>(_ other: Document<PrimaryResourceBody, OtherMeta, OtherLinks, IncludeType, OtherDescription, OtherError>.Body.Data) -> Document.Body.Data {
276-
return Document.Body.Data(primary: primary.appending(other.primary),
277-
includes: includes.appending(other.includes),
278-
meta: meta,
279-
links: links)
275+
public func merging<OtherMeta, OtherLinks, OtherDescription, OtherError>(_ other: Document<PrimaryResourceBody, OtherMeta, OtherLinks, IncludeType, OtherDescription, OtherError>.Body.Data) -> Document<PrimaryResourceBody, OtherMeta, OtherLinks, IncludeType, APIDescription, Error>.Body.Data {
276+
return .init(primary: primary.appending(other.primary),
277+
includes: includes.appending(other.includes),
278+
meta: other.meta,
279+
links: other.links)
280280
}
281281
}
282282

Tests/JSONAPITests/Document/DocumentTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,8 @@ extension DocumentTests {
15431543
let combined = bodyData1.merging(bodyData2)
15441544

15451545
XCTAssertEqual(combined.primary.values, bodyData1.primary.values + bodyData2.primary.values)
1546+
XCTAssertEqual(combined.meta, bodyData2.meta)
1547+
XCTAssertEqual(combined.links, bodyData2.links)
15461548
}
15471549

15481550
public func test_MergeBodyDataWithMergeFunctions() {

0 commit comments

Comments
 (0)