Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions Plugins/SurrealDBDriverPlugin/SurrealValue+Display.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,14 @@ public extension SurrealValue {
}
}

var jsonText: String {
JSONTruncation.truncate(Self.jsonFragment(self), maxLength: Self.maxSerializedLength)
private func jsonText(_ length: SurrealTextLength) -> String {
let json = Self.jsonFragment(self)
switch length {
case .display:
return JSONTruncation.truncate(json, maxLength: Self.maxSerializedLength)
case .whole:
return json
}
}

var typeName: String {
Expand Down
2 changes: 1 addition & 1 deletion TableProTests/Plugins/ElasticsearchDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ struct ElasticsearchStatementGeneratorTests {
}

private func displayed(_ value: Any) -> String {
ElasticsearchMappingFlattener.cell(value).asText ?? ""
ElasticsearchMappingFlattener.cell(value, length: .display).asText ?? ""
}

private func shortenedRefusal(_ column: String) -> PluginRowWriteRefusal {
Expand Down
4 changes: 2 additions & 2 deletions TableProTests/Plugins/TypesenseDriverTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -964,7 +964,7 @@ struct TypesenseStatementGeneratorTests {
}

private func shortenedAuthors() -> String {
TypesenseSchema.cell((0..<1_500).map { "author-\($0)" }).asText ?? ""
TypesenseSchema.cell((0..<1_500).map { "author-\($0)" }, length: .display).asText ?? ""
}

private func shortenedRefusal(_ column: String) -> PluginRowWriteRefusal {
Expand Down Expand Up @@ -1025,7 +1025,7 @@ struct TypesenseStatementGeneratorTests {

@Test("A complete array written over one shortened for display is refused, since it may be the shown part closed")
func updateRefusesACompleteArrayWrittenOverAShortenedOne() throws {
let shownPart = TypesenseSchema.cell((0..<600).map { "author-\($0)" }).asText ?? ""
let shownPart = TypesenseSchema.cell((0..<600).map { "author-\($0)" }, length: .display).asText ?? ""
try #require(!shownPart.hasSuffix("..."))
#expect(throws: shortenedRefusal("authors")) {
try updateRequest(authorsEdit(from: shortenedAuthors(), to: .text(shownPart)))
Expand Down
Loading