-
Notifications
You must be signed in to change notification settings - Fork 87
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
Version 3: Update interfaces and nothing else #108
Comments
If you plan to change it you might want to consider changing the split with SubSelectInterface and SelectInterface it's a bit annoying you cannot get any typehint as you can only typehint on one of interfaces please consider extending the interface for ease of use with an IDE. |
Yes please! I have ended up creating a small wrapper class that fixes some annoyances and adds extra utility functions. For example, adding the ability to include columns from the join table that get automatically prefixed by the table name, a joinLeft() / joinInner(), and extra methods to ease working with subselects (not shown below). class WrappedSelect {
/** @var Aura\SqlQuery\Common\SelectInterface */
private $select;
/**
* Adds a JOIN table and columns to the query.
* @param string $joinType The join type: inner, left, natural, etc.
* @param string $spec The table specification; "real_table" or "real_table AS alias"
* @param string $condition Join on this condition.
* @param array $columns columns as passed to cols()
* @return $this
*/
public function join($joinType, $spec, $condition = null, $columns = null)
{
$this->select->join($joinType, $spec, $condition);
$this->addColumns($columns, $spec);
return $this;
}
/**
* @param string $spec The table specification; "foo" or "foo AS bar".
* @param string $condition Join on this condition.
* @param array $columns columns as passed to cols()
* @return $this
*/
public function joinLeft($spec, $condition = null, $columns = [])
{
return $this->join('left', $spec, $condition, $columns);
}
/**
* Adds a FROM element to the query; quotes the table name automatically.
* @param string $table The table specification; "foo" or "foo AS bar".
* @param array $columns
* @return $this
*/
public function from($table, $columns = [])
{
$this->select->from($table);
$this->addColumns($columns, $table);
return $this;
}
/**
* @param array $columns
* @param string $tableName table name
*/
private function addColumns($columns, $tableName)
{
if (empty($columns)) {
return;
}
if (strpos($tableName, ' ') !== false) {
// if the table spec is a subselect or function or anything funky then just add the raw columns
$this->cols($columns);
return;
}
$resolved = [];
foreach ($columns as $col => $alias) {
if (is_string($col)) {
$col = $tableName . '.' . $col;
} else if (!preg_match('|[.("]|', $alias)) {
// no function call or other weirdness
$alias = $tableName . '.' . $alias;
}
$resolved[$col] = $alias;
}
$this->cols($resolved);
}
// ... etc |
Can we also make several protected methods public and available via the interface? eg reset() and the build* functions, or provide getters for flags (for DISTINCT), groupBy, orderBy, having. I recently built a paginator class that builds a PageInformation data transfer object for a sliding window of pages. Its based on ZF1, ZF2, PagerFanta and jasongrimes/php-paginator. But none of the above support Aura, and seem quite complex for what is actually needed. With the above changes, i can make the paginator even cleaner / clearer and offer it to the Aura project if you want it. |
can you create a v3 branch we can make pull requests against? |
@pavarnos have created a 3.x branch. |
a suggested "ship list" for v3?
I'm OK with doing all this: i have time this week. @harikt has been great at responding quickly. |
@pavarnos I would suggest you to create separate PR's . Small PR's are easy to review and merge. Changes to interfaces in PR may take some time for review and getting merged. I will try my best to respond / merge with my knowledge. Thank you. |
By the way the docs structure will change. I will make the changes soon. |
Don't forget to add hasCols and getCols in interface ;) |
@pavarnos et al: I've just merged a bunch of 3.x-related stuff; let me know how much that moves the checklist forward. |
thanks for all the merges. updated the checklist. i'm short of time to contribute much for the next wee while... |
My apologies, folks -- my recent PRs to the 3.x branch have been over-and-above this plan. After the Quoter PR I will cease, and move on to documentation. Further, I think the Subselect interface can be merged to SelectInterface, so long as we typehint that particular bit of logic to SelectInterface instead of Subselect. Thoughts? |
Sounds good
|
UPDATE : I have made the 3.x as default branch. |
all the things in this issue have now been resolved? can it be closed? |
Looks like it. |
There have been several questions lately regarding the fact that the interfaces do not match the classes. The disconnect is because the classes have had features added, but adding the relevant methods to the interface would be a BC break.
Perhaps the time has come to update the interfaces, and in so doing move to version 3, with no other functionality changes.
Thoughts?
The text was updated successfully, but these errors were encountered: