/**
  * Processes a field of a relation model
  * @param string $name Name of the field
  * @param zibo\library\database\manipulation\expression\TableExpression $table Table expression for the field
  * @param boolean $inCondition Flag to see whether the provided expression is used in a condition or not
  * @return zibo\library\database\manipulation\expression\FieldExpression
  */
 private function processRelationFieldExpression($name, TableExpression $table, $inCondition)
 {
     $tableName = $table->getName();
     try {
         $field = $this->meta->getField($tableName);
     } catch (OrmException $e) {
         if (!isset($this->tables[$tableName])) {
             throw new OrmParseException('Table ' . $tableName . ' is not added to the query');
         }
         return new FieldExpression($name, $this->tables[$tableName], $tableName . self::ALIAS_SEPARATOR . $name);
     }
     $isRelationField = $field instanceof RelationField;
     if ($isRelationField) {
         $this->addFieldJoin($field);
     }
     $relationModel = $this->meta->getRelationModel($tableName);
     $relationField = $relationModel->getMeta()->getField($name);
     if ($relationField->isLocalized()) {
         $table = $this->meta->getRelationLocalizedTable($tableName);
         if ($inCondition && $isRelationField) {
             $joinCondition = $this->createLocalizeCondition($this->meta->getRelationTable($tableName), $table);
             $join = new JoinExpression(JoinExpression::TYPE_LEFT, $table, $joinCondition);
             $this->addConditionJoin($join);
         }
     } else {
         $table = new TableExpression($relationModel->getName(), $tableName);
     }
     return new FieldExpression($name, $table, $tableName . self::ALIAS_SEPARATOR . $name);
 }
 /**
  * Creates a data object for relation data
  * @param string $fieldName Name of the relation field
  * @return mixed Empty data object
  */
 private function createData($fieldName)
 {
     try {
         if (!array_key_exists($fieldName, $this->modelData)) {
             $relationModel = $this->meta->getRelationModel($fieldName);
             $this->modelData[$fieldName] = $relationModel->createData(false);
         }
         $data = clone $this->modelData[$fieldName];
     } catch (Exception $e) {
         $data = new Data();
     }
     return $data;
 }