         // Keyed values require JSON encoding: we need to throw
         // JSONRequiredError. Since we can't throw right from here, let's
         // delegate the job to a dedicated container.
-        requestedJSONContainer = .keyed
+        requiresJSON = true
         let container = JSONRequiredEncoder<Record>.KeyedContainer<Key>(codingPath: codingPath)
         return KeyedEncodingContainer(container)
     }

        // Keyed values require JSON encoding: we need to throw
        // JSONRequiredError. Since we can't throw right from here, let's
        // delegate the job to a dedicated container.
        requestedJSONContainer = .unkeyed
        return JSONRequiredEncoder<Record>(codingPath: codingPath)
    }
    


/// The encoder that encodes into a database column
private class ColumnEncoder<Record: MutablePersistableRecord>: Encoder {
    var recordEncoder: RecordEncoder<Record>
    var key: CodingKey
    var codingPath: [CodingKey] { return [key] }
    var userInfo: [CodingUserInfoKey: Any] { return Record.databaseEncodingUserInfo }
    var requiresJSON = false
    
    init(recordEncoder: RecordEncoder<Record>, key: CodingKey) {
        self.recordEncoder = recordEncoder
