Closed marius-se closed 1 year ago
Merging #365 (c651b1a) into main (689e4aa) will decrease coverage by
0.12%
. The diff coverage is66.66%
.
CI complains about breaking api changes, which is a bit worrying. However we have default implementations for the new non-static psqlType
and psqlFormat
properties, and the rest is just inheritance bubbling up from the two new protocols... sooo that shouldn't cause any problems - or does it?
An additional thought: Would it make sense to also provide utility methods for looking up type OIDs by name (e.g. wrapping
SELECT 'foo'::"regtype"::"integer" as "oid"
), or do we want to leave that to the purview of higher-level packages?
Hmmm personally I feel like this belongs into a higher-level package. As far as I understand PostgresNIO is supposed to provide an interface to build and execute queries, not offer a toolbox of ready-to-use queries. What do you think?
Hmmm personally I feel like this belongs into a higher-level package. As far as I understand PostgresNIO is supposed to provide an interface to build and execute queries, not offer a toolbox of ready-to-use queries. What do you think?
I tend to agree; I pretty much only brought it up to make sure we're all on the same page π.
@gwynne What about this comment?
...providing func
encode<S>(into byteBuffer: inout ByteBuffer, context: PostgresEncodingContext<PostgresJSONEncoder>) where S: Sequence, S.Element: PostgresArrayEncodable { ... }
instead of trying to add protocol conformance.
We would still need to add protocol conformance to the different sequence types, wouldn't we?
Good to hear that you like it! π
We would still need to add protocol conformance to the different sequence types, wouldn't we?
Exactly the opposite - withholding the conformance from any sequence types (including Array
) would remove any ambiguity about which version of encode()
to call, although my original comment should have specified that the additional method(s) would have to be available on PostgresBindings
, not directly on the various encodable protocols. (That's actually what makes it a no more ideal solution than the suggestion of conforming the sequence types one by one - the ability to invoke the encoding logic independently of any supporting types is lost, just as it was when working with any Encodable
pre-Swift 5.7.)
All this being said, that comment was never intended to block this PR; I'd go for trying to address it in a different PR (but before this one gets included in a tagged release, otherwise it'd involve revising public API and it'd be a basically permanent mess).
Ahhh got it!
@fabianfett Ping on this - do you still have any blocking concerns?
@marius-se Ping as well - can you resolve the merge conflicts and bring this up to date with main
?
IIRC all good from my side. @marius-se can you bring this in line with main
? Once done I'll do a final review. Thanks for your work up until here.
@marius-se small ping... shall I move this forward?
Oh sorry @fabianfett! I'm currently traveling through New Zealand (without electricity π ). If you need the changes on main now feel free to take this over! Otherwise I'll be back in 3-4 weeks :)
API breakage checker complain. Will need to research this one:
21 breaking changes detected in PostgresNIO:
π API breakage: protocol PostgresArrayEncodable has added inherited protocol PostgresThrowingDynamicTypeEncodable
π API breakage: protocol PostgresRangeEncodable has added inherited protocol PostgresDynamicTypeEncodable
π API breakage: protocol PostgresRangeEncodable has added inherited protocol PostgresThrowingDynamicTypeEncodable
π API breakage: protocol PostgresRangeArrayEncodable has added inherited protocol PostgresDynamicTypeEncodable
π API breakage: protocol PostgresRangeArrayEncodable has added inherited protocol PostgresThrowingDynamicTypeEncodable
π API breakage: protocol PostgresEncodable has generic signature change from to <Self : PostgresNIO.PostgresThrowingDynamicTypeEncodable>
π API breakage: protocol PostgresEncodable has added inherited protocol PostgresThrowingDynamicTypeEncodable
π API breakage: protocol PostgresNonThrowingEncodable has generic signature change from <Self : PostgresNIO.PostgresEncodable> to <Self : PostgresNIO.PostgresDynamicTypeEncodable, Self : PostgresNIO.PostgresEncodable>
π API breakage: protocol PostgresNonThrowingEncodable has added inherited protocol PostgresDynamicTypeEncodable
π API breakage: protocol PostgresNonThrowingEncodable has added inherited protocol PostgresThrowingDynamicTypeEncodable
π API breakage: func PostgresQuery.StringInterpolation.appendInterpolation(_:) has generic signature change from <Value where Value : PostgresNIO.PostgresEncodable> to <Value where Value : PostgresNIO.PostgresThrowingDynamicTypeEncodable>
π API breakage: func PostgresQuery.StringInterpolation.appendInterpolation(_:) has generic signature change from <Value where Value : PostgresNIO.PostgresEncodable> to <Value where Value : PostgresNIO.PostgresThrowingDynamicTypeEncodable>
π API breakage: func PostgresQuery.StringInterpolation.appendInterpolation(_:) has generic signature change from <Value where Value : PostgresNIO.PostgresNonThrowingEncodable> to <Value where Value : PostgresNIO.PostgresDynamicTypeEncodable>
π API breakage: func PostgresQuery.StringInterpolation.appendInterpolation(_:) has generic signature change from <Value where Value : PostgresNIO.PostgresNonThrowingEncodable> to <Value where Value : PostgresNIO.PostgresDynamicTypeEncodable>
π API breakage: func PostgresQuery.StringInterpolation.appendInterpolation(_:context:) has generic signature change from <Value, JSONEncoder where Value : PostgresNIO.PostgresEncodable, JSONEncoder : PostgresNIO.PostgresJSONEncoder> to <Value, JSONEncoder where Value : PostgresNIO.PostgresThrowingDynamicTypeEncodable, JSONEncoder : PostgresNIO.PostgresJSONEncoder>
π API breakage: func PostgresBindings.append(_:) has generic signature change from <Value where Value : PostgresNIO.PostgresEncodable> to <Value where Value : PostgresNIO.PostgresThrowingDynamicTypeEncodable>
π API breakage: func PostgresBindings.append(_:context:) has generic signature change from <Value, JSONEncoder where Value : PostgresNIO.PostgresEncodable, JSONEncoder : PostgresNIO.PostgresJSONEncoder> to <Value, JSONEncoder where Value : PostgresNIO.PostgresThrowingDynamicTypeEncodable, JSONEncoder : PostgresNIO.PostgresJSONEncoder>
π API breakage: func PostgresBindings.append(_:) has generic signature change from <Value where Value : PostgresNIO.PostgresNonThrowingEncodable> to <Value where Value : PostgresNIO.PostgresDynamicTypeEncodable>
π API breakage: func PostgresBindings.append(_:context:) has generic signature change from <Value, JSONEncoder where Value : PostgresNIO.PostgresNonThrowingEncodable, JSONEncoder : PostgresNIO.PostgresJSONEncoder> to <Value, JSONEncoder where Value : PostgresNIO.PostgresDynamicTypeEncodable, JSONEncoder : PostgresNIO.PostgresJSONEncoder>
π API breakage: func PostgresEncodable.encode(into:context:) has been removed
π API breakage: func PostgresNonThrowingEncodable.encode(into:context:) has been removed
@marius-se Thanks so much for pushing this through!
Closes #333
Example: