Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add JSON support #54

Merged
merged 28 commits into from
Sep 23, 2024
Merged

Add JSON support #54

merged 28 commits into from
Sep 23, 2024

Conversation

lovetodream
Copy link
Owner

@lovetodream lovetodream commented Jul 6, 2024

This introduces a new public type OracleJSON. OracleJSON conforms to OracleDecodable when its Value is Decodable. It conforms to OracleEncodable when its Value conforms to Encodable.

OracleDecodingContext does no longer require a JSONDecoder. It has no public initializer anymore. This is a breaking change affecting everyone who implements custom OracleDecodable or OracleCodable conformances. To resolve the breakage, remove the generic JSONDecoder from OracleDecodingContext:

extension MyType: OracleDecodable {
-   public init<JSONDecoder: OracleJSONDecoder>(
+   public init(
        from buffer: inout ByteBuffer,
        type: OracleDataType,
-       context: OracleDecodingContext<JSONDecoder>
+       context: OracleDecodingContext
    ) throws
}

The same change is made for OracleEncodingContext and its OracleJSONEncoder:

extension MyType: OracleEncodable {
-    public func encode<JSONEncoder: OracleJSONEncoder>(
+    public func encode(
        into buffer: inout ByteBuffer,
-       context: OracleEncodingContext<JSONEncoder>
+       context: OracleEncodingContext
    )
}

Copy link

codecov bot commented Jul 6, 2024

Codecov Report

Attention: Patch coverage is 96.93265% with 143 lines in your changes missing coverage. Please review.

Project coverage is 87.06%. Comparing base (2deceb0) to head (d270b05).

Files with missing lines Patch % Lines
Sources/OracleNIO/Data/JSON/OracleJSONWriter.swift 92.99% 26 Missing ⚠️
...rces/OracleNIO/Data/JSON/OracleJSON+Encoding.swift 94.94% 22 Missing ⚠️
Sources/OracleNIO/Data/JSON/OracleJSONParser.swift 95.05% 19 Missing ⚠️
Sources/OracleNIO/Data/OracleVector.swift 80.24% 16 Missing ⚠️
...ions/ByteBuffer/ByteBuffer+ThrowingReadBytes.swift 25.00% 15 Missing ⚠️
...ns/ByteBuffer/ByteBuffer+ThrowingReadInteger.swift 52.38% 10 Missing ⚠️
...ons/ByteBuffer/ByteBuffer+ThrowingReadString.swift 50.00% 10 Missing ⚠️
...ources/OracleNIO/Data/JSON/OracleJSONStorage.swift 70.00% 9 Missing ⚠️
...rces/OracleNIO/Data/IntervalDS+OracleCodable.swift 66.66% 6 Missing ⚠️
...rces/OracleNIO/Data/JSON/OracleJSON+Decoding.swift 99.10% 6 Missing ⚠️
... and 4 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #54      +/-   ##
==========================================
+ Coverage   81.64%   87.06%   +5.42%     
==========================================
  Files         130      140      +10     
  Lines       14866    19145    +4279     
==========================================
+ Hits        12137    16669    +4532     
+ Misses       2729     2476     -253     
Flag Coverage Δ
87.06% <96.93%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...onnectionStateMachine/ConnectionStateMachine.swift 72.91% <100.00%> (+0.04%) ⬆️
Sources/OracleNIO/Data/Bool+OracleCodable.swift 0.00% <ø> (ø)
...rces/OracleNIO/Data/ByteBuffer+OracleCodable.swift 87.50% <ø> (ø)
Sources/OracleNIO/Data/Bytes+OracleCodable.swift 0.00% <ø> (ø)
Sources/OracleNIO/Data/Cursor.swift 68.96% <ø> (ø)
Sources/OracleNIO/Data/Data+OracleCodable.swift 82.35% <ø> (ø)
Sources/OracleNIO/Data/Date+OracleCodable.swift 93.85% <ø> (ø)
Sources/OracleNIO/Data/Double+OracleCodable.swift 68.62% <ø> (ø)
Sources/OracleNIO/Data/Float+OracleCodable.swift 80.64% <ø> (ø)
Sources/OracleNIO/Data/Int+OracleCodable.swift 19.56% <ø> (ø)
... and 37 more

... and 4 files with indirect coverage changes

@lovetodream lovetodream added this to the 1.0.0 milestone Aug 7, 2024
OracleDecodingContext does no longer require a JSONDecoder, also has no public initializer anymore as it is currently empty but might get stuff later, then we'll add a pulic initializer with those params. This is a breaking change affecting everyone who implements custom `OracleDecodable` or `OracleCodable` conformances.
@lovetodream lovetodream added the semver-major Breaks existing public API. label Sep 17, 2024
@kicsipixel
Copy link

Looking forward to testing it, app is ready only JSON support is missing :)

@lovetodream lovetodream marked this pull request as ready for review September 21, 2024 16:04
@lovetodream lovetodream merged commit cbedc27 into main Sep 23, 2024
6 of 7 checks passed
@lovetodream lovetodream deleted the feature/oracle-json branch September 23, 2024 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver-major Breaks existing public API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants