Feature/upsert#224
Feature/upsert#224puzzledpolymath wants to merge 5 commits intocycle:2.xfrom puzzledpolymath:feature/upsert
Conversation
|
One thing I'm uncertain about or dislike at the moment, is the need to specify conflicting index column names for non MySQL drivers. Having said that, most database layers operate in this way, making the user specify conflicting columns. While likely not an appropriate location for such logic, perhaps something like below could work. E.g. gather info from the schema to determine unique indexes and their columns. class UpsertQuery extends ActiveQuery
{
public function getTokens(): array
{
$conflicts = $this->conflicts;
if ($conflicts === [] && $this->driver) {
$schema = $this->driver->getSchemaHandler()->getSchema($this->table);
foreach ($schema->getIndexes() as $index) {
if ($index->isUnique()) {
$conflicts = $conflicts + $index->getColumns();
}
}
$conflicts = array_unique($conflicts);
}
return [
'table' => $this->table,
'columns' => $this->columns,
'values' => $this->values,
'conflicts' => $conflicts,
];
}
} |
|
@roxblnfk is there anything needed from me to get past that labeler error? Warning: The action requires write permission to add labels to pull requests. For more information please refer to the action documentation: https://github.com/actions/labeler#permissions |
No, don't worry about it. |
# Conflicts: # src/Driver/CompilerInterface.php
|
Latest changes have been merged, I've bumped public const SUBQUERY = 9;
public const UPSERT_QUERY = 10; |
|
I haven't had time to look at this PR yet, but it seems you've done a great job. Why did you decide to close it? |
|
I deleted the forked repositories forgetting this PR was still open, I’ll sort it out first thing in the morning |
This pull request adds support for performing
upsertqueries. Ticket #50 is what sparked interest for this feature.🔍 What was changed
🤔 Why?
📝 Checklist
📃 Documentation
Note that specifying conflict index column names is redundant and not required for
MySQL.PHP
MyQL
Postgres / SQLite
MSSQL