Skip to content

Avoid using PostgresData - #283

Open
ptoffy wants to merge 5 commits into
mainfrom
avoid-postgresdata
Open

ptoffy wants to merge 5 commits into
mainfrom
avoid-postgresdata

Conversation

@ptoffy

@ptoffy ptoffy commented Sep 21, 2026

Copy link
Copy Markdown
Member

We should use PostgresEncodable

@ptoffy
ptoffy requested a review from gwynne as a code owner September 21, 2026 17:47
@codecov

codecov Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.48936% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 52.60%. Comparing base (11d6910) to head (9d5fe57).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
Sources/PostgresKit/PostgresDataTranslation.swift 91.48% 16 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #283      +/-   ##
==========================================
+ Coverage   45.90%   52.60%   +6.69%     
==========================================
  Files          13       13              
  Lines         891     1038     +147     
==========================================
+ Hits          409      546     +137     
- Misses        482      492      +10     
Files with missing lines Coverage Δ
Sources/PostgresKit/PostgresDataTranslation.swift 80.00% <91.48%> (+6.29%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread Sources/PostgresKit/PostgresDataTranslation.swift Outdated
Comment on lines -245 to -268
let encoded1 = try PostgresDataTranslation.encode(codingPath: [], userInfo: [:], value: [-1, nil, nil, nil] as [Int?], in: .default, file: #fileID, line: #line)
#expect(encoded1.type == .int8Array && encoded1.array?.count == 4)
#expect(encoded1.array?.dropFirst(0).first?.type == .int8 && encoded1.array?.dropFirst(0).first?.int == -1)
#expect(encoded1.array?.dropFirst(1).first?.type == .int8 && encoded1.array?.dropFirst(1).first?.value == nil)
#expect(encoded1.array?.dropFirst(2).first?.type == .int8 && encoded1.array?.dropFirst(2).first?.value == nil)
#expect(encoded1.array?.dropFirst(3).first?.type == .int8 && encoded1.array?.dropFirst(3).first?.value == nil)
let encoded2 = try PostgresDataTranslation.encode(codingPath: [], userInfo: [:], value: [nil, nil, nil, nil] as [Int?], in: .default, file: #fileID, line: #line)
#expect(encoded2.type == .int8Array && encoded2.array?.count == 4)
#expect(encoded2.array?.dropFirst(0).first?.type == .int8 && encoded2.array?.dropFirst(0).first?.value == nil)
#expect(encoded2.array?.dropFirst(1).first?.type == .int8 && encoded2.array?.dropFirst(1).first?.value == nil)
#expect(encoded2.array?.dropFirst(2).first?.type == .int8 && encoded2.array?.dropFirst(2).first?.value == nil)
#expect(encoded2.array?.dropFirst(3).first?.type == .int8 && encoded2.array?.dropFirst(3).first?.value == nil)
let encoded3 = try PostgresDataTranslation.encode(codingPath: [], userInfo: [:], value: [.one, nil, nil, nil] as [Bar?], in: .default, file: #fileID, line: #line)
#expect(encoded3.type == .int8Array && encoded3.array?.count == 4)
#expect(encoded3.array?.dropFirst(0).first?.type == .int8 && encoded3.array?.dropFirst(0).first?.int == 0)
#expect(encoded3.array?.dropFirst(1).first?.type == .int8 && encoded3.array?.dropFirst(1).first?.value == nil)
#expect(encoded3.array?.dropFirst(2).first?.type == .int8 && encoded3.array?.dropFirst(2).first?.value == nil)
#expect(encoded3.array?.dropFirst(3).first?.type == .int8 && encoded3.array?.dropFirst(3).first?.value == nil)
let encoded4 = try PostgresDataTranslation.encode(codingPath: [], userInfo: [:], value: [nil, nil, nil, nil] as [Bar?], in: .default, file: #fileID, line: #line)
#expect(encoded4.type == .int8Array && encoded4.array?.count == 4)
#expect(encoded4.array?.dropFirst(0).first?.type == .int8 && encoded4.array?.dropFirst(0).first?.value == nil)
#expect(encoded4.array?.dropFirst(1).first?.type == .int8 && encoded4.array?.dropFirst(1).first?.value == nil)
#expect(encoded4.array?.dropFirst(2).first?.type == .int8 && encoded4.array?.dropFirst(2).first?.value == nil)
#expect(encoded4.array?.dropFirst(3).first?.type == .int8 && encoded4.array?.dropFirst(3).first?.value == nil)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all still pass right?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah these were just modified to do

let value1 = [-1, nil, nil, nil]
let encoded1 = try PostgresDataTranslation.encode(
    codingPath: [], userInfo: [:], value: value1, in: .default, file: #fileID, line: #line
)
#expect(encoded1?.psqlType == .int8Array)
#expect(try PostgresDataTranslation.decode([Int?].self, from: .init(with: encoded1), in: .default) == value1)

instead

@gwynne

gwynne commented Sep 23, 2026

Copy link
Copy Markdown
Member

I like this but I want to look at it a bit more first.

@gwynne gwynne left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not merge yet

@gwynne gwynne added the semver-patch Internal changes only label Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

semver-patch Internal changes only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants