'data || :data', Mode::SQLite => 'json_patch(data, json(:data))', default => throw new DocumentException('Database mode not set; cannot make patch statement') }; return "UPDATE $tableName SET data = $setValue WHERE $whereClause"; } /** * Query to patch (partially update) a document by its ID * * @param string $tableName The name of the table in which a document should be patched * @return string The query to patch a document by its ID * @throws DocumentException If the database mode has not been set */ public static function byId(string $tableName): string { return self::update($tableName, Query::whereById()); } /** * Query to patch (partially update) a document via a comparison on a JSON field * * @param string $tableName The name of the table in which documents should be patched * @param array|Field[] $field The field comparison to match * @param string $conjunction How to handle multiple conditions (optional; defaults to `AND`) * @return string The query to patch documents via field comparison * @throws DocumentException If the database mode has not been set */ public static function byFields(string $tableName, array $field, string $conjunction = 'AND'): string { return self::update($tableName, Query::whereByFields($field, $conjunction)); } }