I have a schema.yml file defined this way:
email:
actAs: { Timestampable: ~ }
columns:
id: { type: integer, notnull: true, unique: true, primary: true }
correo: { type: string(255), notnull: true }
nombre: { type: string(255), notnull: true }
apellido: { type: string(255), notnull: true }
lista:
actAs: { Timestampable: ~ }
columns:
id: { type: integer, notnull: true, unique: true, primary: true }
nombre: { type: string(255), notnull: true }
descripcion: { type: string(255), notnull: false }
email_lista:
actAs: { Timestampable: ~ }
columns:
email_id: { type: integer }
lista_id: { type: integer }
relations:
email: { onDelete: CASCADE, local: email_id, foreign: id, foreignAlias: emailrelation }
lista: { onDelete: CASCADE, local: lista_id, foreign: id, foreignAlias: listarelation }
Then, I try to fetch all the records from the email model that do not belong to lista with lista_id equals to one.
Here’s the method on the emailTable.php class:
public function getEmailsNotBlacklist()
{
$q = $this->createQuery('c')
->leftJoin('c.email_lista m')
->Where('m.lista_id != ?',1);
->orderBy('m.lista_id ASC');
return $q->execute();
}
The result is an error:

What might be causing this?
Here is the code that would not come up with an error:
What I was taking wrong was that the foreignAlias is what is to be referenced in the join, and not the name of the model.