public function convertToDatabaseValue($value, $connection, $prepared = false)
    {
        if (false === $prepared) {
            $value = $this->prepareValue($value);
        }

        return Type::getType($this->dbType($connection))
            ->convertToDatabaseValue(
                $value,
                $connection->getDatabasePlatform()
            );
    }