Skip to content

Commit

Permalink
Add failing test for regression
Browse files Browse the repository at this point in the history
We have a project that started failing row decoding when upgrading from 3.28.0. I haven't dug into the problem but was able to sketch out a failing test that I believe should pass in 3.28.0 (wasn't able to easily confirm because the testing infrastructure on `main` didn't exist back then).
  • Loading branch information
stephencelis authored Jul 3, 2024
1 parent f697d32 commit 9e389f4
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Tests/SQLKitTests/SQLRowDecoderTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,17 @@ final class SQLRowDecoderTests: XCTestCase {
XCTAssertEqual(Array<any CodingKey>().map(\.stringValue), context.codingPath.map(\.stringValue))
}
}

func testSnakeCase_CodableKeyTransformation() throws {
struct Episode: Decodable, Equatable {
var userID: Int
}

XCTAssertEqual(
try SQLRowDecoder(keyDecodingStrategy: .convertFromSnakeCase).decode(Episode.self, from: TestRow(data: ["user_id": "1"])),
Episode(userID: 1)
)
}
}

enum TestDecEnum: Codable {
Expand Down

0 comments on commit 9e389f4

Please sign in to comment.