Skip to content

Commit

Permalink
fix empty array encoding crash
Browse files Browse the repository at this point in the history
in case of an empty container, the encoder returns nil so we need to check
for that and throw a _DoJSONError to fall back to JSON encoding like with
non empty arrays
  • Loading branch information
FredericRuaudel committed Jun 26, 2018
1 parent db41d50 commit 04afb7c
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Sources/SQLite/Codable/SQLiteDataEncoder.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ public struct SQLiteDataEncoder {
let encoder = _Encoder()
do {
try value.encode(to: encoder)
return encoder.data!
guard let data = encoder.data else { throw _DoJSONError() }
return data
} catch is _DoJSONError {
struct AnyEncodable: Encodable {
var encodable: Encodable
Expand Down

0 comments on commit 04afb7c

Please sign in to comment.