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

test for via() is bad and doesn't reveal that via() is in fact broken #52

Closed
xpavp03 opened this issue Dec 10, 2012 · 3 comments
Closed

Comments

@xpavp03
Copy link

xpavp03 commented Dec 10, 2012

I've had problems using via() in my project which led me to your tests. The test for via() appeared to be working until I removed author_id attribute from the database.

Then I found an easier way to prove that the test is a bogus. I enabled query logging by removing your comment in connect.inc.php ($software->debug = true;).

This is the result:

php -f run-tests.php
12-via.phpt:7:SELECT * FROM author;
12-via.phpt:8:SELECT * FROM application WHERE (application.author_id IN (11, 12));
0.012 s, 974 KiB

Please notice that although the test code asks for maintainer_id to be used, author_id is used instead.

foreach ($software->author() as $author) {
    foreach ($author->application()->via("maintainer_id") as $application) {
        echo "$author[name]: $application[title]\n";
    }
}

Here's a very ugly workaround for the via() bug:

function via($column) {
  // workaround begin
  $oldCondition = $this->table . "." . $this->column . " IN " . $this->quote(array_keys((array) $this->result->rows));
  $newCondition = $this->table . "." . $column . " IN " . $this->quote(array_keys((array) $this->result->rows));
  foreach ($this->where as &$condition) {
    if ($condition == $oldCondition) {
      $condition = $newCondition;
      break;
    }
  }
  // workaround end
  $this->column = $column;
  return $this;
}
@itsnotvalid
Copy link

I can confirm that it's still problematic.
Try (string) $author->application()->via("maintainer_id") and it should show a query with problems.

@TomasVotruba
Copy link

Ping...

@itsnotvalid
Copy link

Abandoned?

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

3 participants