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

Nodes insert error #6

Open
miwe01 opened this issue Jul 8, 2022 · 2 comments
Open

Nodes insert error #6

miwe01 opened this issue Jul 8, 2022 · 2 comments

Comments

@miwe01
Copy link

miwe01 commented Jul 8, 2022

When you add just nodes in the graph and no edges, you get an error in the function getCommitQuery().

One solution to fix the issue.

public function getCommitQuery(): QueryInterface
    {
        $query = 'CREATE ';
        foreach ($this->nodes as $index => $node) {
            $query .= $node->toString(); // split the $query in $query->toSring() and ', '
            if ($index < count($this->nodes) - 1) { // added this line  
                $query .= ',';
            }
        }
        $edgeCount = count($this->edges);
        if(!empty($edgeCount)){ // check or you get an error
            if(count($this->nodes) != 0)
                $query .= ', '; // added this line
            foreach ($this->edges as $index => $edge) {
                $query .= $edge->toString();
                if ($index < $edgeCount - 1) {
                    $query .= ',';
                }
            }
        }
        return new Query($this->name, $query);
    }
@hkulekci
Copy link

hkulekci commented Jul 9, 2022

I think tests are missing, too. Could you send a PR with tests?

@miwe01
Copy link
Author

miwe01 commented Jul 9, 2022

I didn't test much, I was just inserting some nodes without edges and then I got an error and looked through the code.

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

No branches or pull requests

2 participants