vapor / sql-kit

*️⃣ Build SQL queries in Swift. Extensible, protocol-based design that supports DQL, DML, and DDL.
MIT License
248 stars 58 forks source link

Allow to pass keyDecodingStrategy in first(decoding:) and all(decoding:) #161

Closed valerianb closed 6 months ago

valerianb commented 1 year ago

When inserting, you can specify a keyEncodingStrategy:

try db.insert(into: myTable)
  .model(myModel, keyEncodingStrategy: .convertToSnakeCase)
  .run()

This change allows to pass a keyDecodingStrategy when using the convenience methods to decode models directly:

db.select()
  .from(myTable)
  .all(decoding: MyModel.self, keyDecodingStrategy: .convertFromSnakeCase)
codecov-commenter commented 1 year ago

Codecov Report

Merging #161 (baf26a3) into main (a5c3df4) will not change coverage. The diff coverage is 0.00%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #161 +/- ## ======================================= Coverage 69.27% 69.27% ======================================= Files 94 94 Lines 3486 3486 ======================================= Hits 2415 2415 Misses 1071 1071 ``` | Flag | Coverage Δ | | |---|---|---| | unittests | `69.27% <0.00%> (ø)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#carryforward-flags-in-the-pull-request-comment) to find out more. | [Impacted Files](https://codecov.io/gh/vapor/sql-kit/pull/161?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor) | Coverage Δ | | |---|---|---| | [Sources/SQLKit/Builders/SQLQueryFetcher.swift](https://codecov.io/gh/vapor/sql-kit/pull/161?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=vapor#diff-U291cmNlcy9TUUxLaXQvQnVpbGRlcnMvU1FMUXVlcnlGZXRjaGVyLnN3aWZ0) | `28.94% <0.00%> (ø)` | |
gwynne commented 6 months ago

This was addressed by #172