public function filterQuery(&$selects)
	{
		$model = $this->config->getDataModel();
		$joins = $where = '';
		$columnName = $this->getOption('column_name');
		$nested = $this->getOption('nested');
		$num_pieces = sizeof($nested['pieces']);

		//if there is more than one nested relationship, we need to join all the tables
		if ($num_pieces > 1)
		{
			for ($i = 1; $i < $num_pieces; $i++)
			{
				$model = $nested['models'][$i];
				$relationship = $model->{$nested['pieces'][$i]}();
				$relationship_model = $relationship->getRelated();
				$table = $this->tablePrefix . $relationship_model->getTable();
				$alias = $columnName . '_' . $table;
				$last_alias = $columnName . '_' . $this->tablePrefix . $model->getTable();
				$joins .= ' LEFT JOIN ' . $table . ' AS ' . $alias .
							' ON ' . $alias . '.' . $relationship->getOtherKey() .
								' = ' . $last_alias . '.' . $relationship->getForeignKey();
			}
		}

		$first_model = $nested['models'][0];
		$first_piece = $nested['pieces'][0];
		$first_relationship = $first_model->{$first_piece}();
		$relationship_model = $first_relationship->getRelated();
		$from_table = $this->tablePrefix . $relationship_model->getTable();
		$field_table = $columnName . '_' . $from_table;

		$where = $this->tablePrefix . $first_model->getTable() . '.' . $first_relationship->getForeignKey() .
					' = ' .
					$field_table . '.' . $first_relationship->getOtherKey();

		$selects[] = $this->db->raw("(SELECT " . $this->getOption('select') . "
										FROM " . $from_table." AS " . $field_table . ' ' . $joins . "
										WHERE " . $where . ") AS " . $this->db->getQueryGrammar()->wrap($columnName));
	}