public function initSelectQuery($model, $query)
    {
        // if ON is set, we don't have to worry about anything
        if ($this->on) {
            $query->join(
                $this->foreign_table.' '.$this->foreign_alias,
                $this->on instanceof \atk4\dsql\Expression ? $this->on : $model->expr($this->on),
                $this->kind
            );

            return;
        }

        $query->join(
            $this->foreign_table.(isset($this->foreign_alias) ? (' '.$this->foreign_alias) : ''),
            $model->expr('{}.{} = {}', [
                (isset($this->foreign_alias) ? $this->foreign_alias : $this->foreign_table),
                $this->foreign_field,
                $this->owner->getField($this->master_field),
            ]),
            $this->kind
        );

        /*
        if ($this->reverse) {
            $query->field([$this->short_name => ($this->join ?:
                (
                    (isset($this->owner->table_alias) ? $this->owner->table_alias : $this->owner->table)
                    .'.'.$this->master_field)
            )]);
        } else {
            $query->field([$this->short_name => $this->foreign_alias.'.'.$this->foreign_field]);
        }
         */
    }