Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unnecessary line in class Create #68

Open
oam333 opened this issue Nov 23, 2021 · 1 comment
Open

Unnecessary line in class Create #68

oam333 opened this issue Nov 23, 2021 · 1 comment

Comments

@oam333
Copy link

oam333 commented Nov 23, 2021

Method "setBody" of class "Create" has unnecessary line # 37 (of origin file /phpClient/vendor/manticoresoftware/manticoresearch-php/src/Manticoresearch/Endpoints/Indices/Create.php).

See comment inside code:

public function setBody($params = null)
{
    if (isset($this->index)) {
        $columns = [];
        if (isset($params['columns'])) {
            foreach ($params['columns'] as $name => $settings) {
                $column = $name . ' ' . $settings['type'];
                if (isset($settings['options']) && count($settings['options']) > 0) {
                    $column .= ' ' . implode(' ', $settings['options']);
                }
                $columns[] = $column;
            }
        }
        $options = "";
        if (isset($params['settings'])) {
            foreach ($params['settings'] as $name => $value) {
                $options.=" ".$name." = '".$value."'";       // ##### <----- this line is unneccessary, because the same code lower in "else" block
                if (is_array($value)) {
                    foreach ($value as $v) {
                        $options.=" ".$name." = '".$v."'";
                    }
                } else {
                    $options.=" ".$name." = '".$value."'"; // #### <----- the same code
                }
            }
        }
        return parent::setBody(['query' => "CREATE TABLE ".
            (isset($params['silent']) && $params['silent']===true?' IF NOT EXISTS ':'').
            $this->index.
            (count($columns)>0?"(".implode(",", $columns).")":" ")
            .$options]);
    }
    throw new RuntimeException('Index name is missing.');
}
@sanikolaev
Copy link
Collaborator

Hello @oam333

Thank you for this issue. We'll be glad to accept your pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants