Skip to content

*edit - sort callback usage #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xsuchy09
Copy link

I think that this is better implementation for user sorting function for this data source. Or not?

@xsuchy09
Copy link
Author

Similar change for Nette 2.4 ...
v1.1.1...xsuchy09:v1.1.2

@paveljanda
Copy link
Member

Can you please describe what is the difference in usage? Thanks

@xsuchy09
Copy link
Author

xsuchy09 commented Nov 25, 2019

See your email ... I wrote you 1st November ... but basic is that I think that this code is better for use. I don't see any reason why to deal with whole SQL when I want to change just ordering.

@xsuchy09
Copy link
Author

xsuchy09 commented Nov 26, 2019

Only one drawback - it is not possible to sort by multiple columns at once. Maybe I just need a demonstration of the use of the current implementation of user sorting.

@xsuchy09
Copy link
Author

It can be easy solved with change in QueryHelper::orderBy method:

	public function orderBy($column, $order)
	{
		if (false === array_key_exists('ORDER', $this->query)) {
			$this->query['ORDER'] = [];
		}
		$this->query['ORDER'][] = [
			'expr_type' => 'colref',
			'base_expr' => $column,
			'no_quotes' => [
				'delim' => FALSE,
				'parts' => [$column]
			],
			'subtree'   => FALSE,
			'direction' => $order
		];

		return $this->sqlCreator->create($this->query);
	}

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

Successfully merging this pull request may close these issues.

2 participants