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

The method allPopulate in ActiveQuery will execute populate twice during execution #286

Open
niqingyang opened this issue Jan 4, 2024 · 0 comments
Labels

Comments

@niqingyang
Copy link
Contributor

What steps will reproduce the problem?

The method allPopulate in ActiveQuery will execute populate twice during execution.

Is this how it was designed or is it a bug ?

   public function all(): array
    {
        if ($this->shouldEmulateExecution()) {
            return [];
        }

        return $this->populate($this->createCommand()->queryAll(), $this->indexBy); // Repeated execution
    }

    public function allPopulate(): array
    {
        $rows = $this->all();

        if ($rows !== []) {
            $rows = $this->populate($rows, $this->indexBy); // Repeated execution
        }

        return $rows;
    }

What is the expected result?

populate should only be executed once ?

What do you get instead?

populate executed twice

Additional info

Q A
Version 1.0.?
PHP version 8.1
Operating system windows 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants