useQuery complains that can't find model query class #598

Open
aramkarapetian opened this Issue Feb 12, 2013 · 8 comments

Projects

None yet

3 participants

@aramkarapetian

replaced line in ModelCriteria::useQuery()
$className = $this->joins[$relationName]->getTableMap()->getPhpName();
with
$className = $this->joins[$relationName]->getTableMap()->getClassName();
and now it's fine.

Not sure if it's right solution but worked for me.

@staabm
Propel member

Could you provide a failing testcase?

@aramkarapetian

not sure have that much time.
will try to describe as much as possible
have two tables called client(person alias) and person(personperson alias)
tried to join person to client using aliases
$clientQuery->join('PersonPerson')->useQuery('PersonPerson')-> ...
what I saw it translates alias properly but when tries to autoload class uses PhpName which does not contain namespace as I saw in map class

@staabm
Propel member

maybe you could post the schema of the related tables..?

@aramkarapetian

Sure

<table name="client">
        <column name="id" sqlType="INT(10) UNSIGNED" primaryKey="true" autoIncrement="true" required="true" />
        <column name="status" sqlType="INT(10) UNSIGNED" required="true" defaultValue="2" />
</table>

<table name="person">
        <column name="client_id" sqlType="INT(10) UNSIGNED" required="true" primaryKey="true" />
        <foreign-key foreignTable="client" onDelete="CASCADE">
            <reference local="client_id" foreign="id" />
        </foreign-key>
</table>

Github hides xml so removed <'s

@staabm
Propel member

And your query which doesn work..

@aramkarapetian
$this->getQuery(array('PersonPerson')) // returns client query, pre-joined with person and aliased
                ->useQuery('PersonPerson')
                    ->innerJoinPersonAccessRoleRelatedByPersonId()
                    ->usePersonAccessRoleRelatedByPersonIdQuery()
                        ->innerJoinAccessRole()
                        ->useAccessRoleQuery()
                            ->innerJoinAccessRoleRight()
                            ->useAccessRoleRightQuery()
                                ->innerJoinAccessRight('PersonAccessRight')
                                ->where('PersonAccessRight.SystemName = ?', $accessRightName)
                            ->endUse()
                        ->endUse()
                    ->endUse()
                ->endUse();
@marcj
Propel member

@aramkarapetian, you can surround your xml by

```xml
<code belong here />
```

to make it visible. I just edited your post.

@marcj
Propel member

The error is probably in runtime/lib/query/PropelQuery.php +23. Since ModelCriteria::getClassAndAlias returns only the phpName it doen't generate the full php class name.

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