public function databaseFields($class, $aggregated = true)
    {
        $class = ClassInfo::class_name($class);
        if ($class === DataObject::class) {
            return [];
        }
        $this->cacheDatabaseFields($class);
        $fields = $this->databaseFields[$class];

        if (!$aggregated) {
            return $fields;
        }

        // Recursively merge
        $parentFields = $this->databaseFields(get_parent_class($class));
        return array_merge($fields, array_diff_key($parentFields, $fields));
    }