         // 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
+        requiresJSON = true
         return JSONRequiredEncoder<Record>(codingPath: codingPath)
     }
     

        // 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
        let container = JSONRequiredEncoder<Record>.KeyedContainer<Key>(codingPath: codingPath)
        return KeyedEncodingContainer(container)
    }

                // error happens, we'll switch to JSON encoding.
                let encoder = ColumnEncoder(recordEncoder: self, key: key)
                try value.encode(to: encoder)
                if encoder.requiresJSON {
                    // Here we handle empty arrays and dictionaries.
                    throw JSONRequiredError()
                }
            } catch is JSONRequiredError {
                // Encode to JSON
