Problem/Motivation
The minimum required version of PostgreSQL is 10. In the Connection class of the PostgreSQL driver we have the following code:
public function upsert($table, array $options = []) {
// Use the (faster) native Upsert implementation for PostgreSQL >= 9.5.
if (version_compare($this->version(), '9.5', '>=')) {
$class = $this->getDriverClass('NativeUpsert');
}
else {
$class = $this->getDriverClass('Upsert');
}
return new $class($this, $table, $options);
}
The method is no longer necessary.
Proposed resolution
1. Remove the method Drupal\Core\Database\Driver\pgsql\Connection::upsert().
2. Then remove the class Drupal\Core\Database\Driver\pgsql\Upsert.
3. After that rename the class Drupal\Core\Database\Driver\pgsql\NativeUpsert to Drupal\Core\Database\Driver\pgsql\Upsert.
4. In the renamed class, change the class name from "NativeUpsert" to "Upsert" and remove the link to http://www.postgresql.org/docs/9.5/static/sql-insert.html#SQL-ON-CONFLICT.
5. The file "core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestPgsql/NativeUpsert.php" can also be removed.
Remaining tasks
TBD
User interface changes
None
API changes
None
Data model changes
None
Release notes snippet
TBD
| Comment | File | Size | Author |
|---|---|---|---|
| #22 | the-upsert-class-was-removed-for-PostgreSQL-database-driver-3129560-21.patch | 12.58 KB | rik-dev |
Comments
Comment #2
daffie commentedComment #3
daffie commentedComment #4
rik-dev commentedComment #5
rik-dev commentedComment #6
daffie commentedUnfortunately the patch does not apply. Therefore I am not able to do a full review. Most of what the patch should do is correct. For now I have only 2 remarks:
This use-statement will still be needed. This class is a subclass of the base Upsert class.
This change is not necessary.
Comment #7
rik-dev commented@daffie Thanks for took it to look. The patch was updated.
Comment #8
rik-dev commentedComment #9
daffie commented@rik-dev: Your newest patch does not apply on my local machine. Did you do a "git pull" before creating your patch?
Comment #10
rik-dev commented@daffie sure, I made "git pull" before patch that. Try this one.
Comment #11
rik-dev commented@daffie After renamed the file
Drupal\Core\Database\Driver\pgsql\NativeUpserttoDrupal\Core\Database\Driver\pgsql\UpsertI got the same error, what do I do wrong?Comment #12
daffie commented@rik-dev: Are you using the 9.1.x branch?
Comment #13
rik-dev commented@daffie: no, I’m using 9.0 branch?
Comment #14
daffie commented@rik-dev: Did you do a
git mv ...? See: https://git-scm.com/docs/git-mv.Comment #15
daffie commentedThe patch should land in the 9.1.x branch. Please use that branch.
Comment #16
rik-dev commented@daffie: sorry, Previously I made some patches for the 9.0 version and I didn't notice it. Thanks man:)
Comment #18
rik-dev commentedComment #19
daffie commentedWaiting for the result of the testbot.
One nitpick:
This line does not need to be added here. The extra line in the docblock.
@rik-dev: Could you with the naming of patches take into account the comment number. Now they are all pointing to comment #5. Thank you for working on this issue.
Comment #20
rik-dev commented@daffie: Yeap, sure. Thanks for your feedback.
Comment #21
daffie commentedBack to needs work for the nitpick from comment #19.
Comment #22
rik-dev commentedThis is a little change from comment #19. I did it, no worries.
Comment #23
rik-dev commentedComment #24
daffie commentedAll code changes look good to me.
For me it is RTBC.
Comment #25
rik-dev commentedComment #26
alexpottDo we care about BC here? Like will this break the fallback driver. To me it looks like it will - see https://git.drupalcode.org/project/pgsql_fallback/-/blob/1.0.x/src/Drive...
Comment #27
daffie commentedAFAIK there is no need for a BC layer. After this patch lands the PostgreSQL fallback driver has then only an unused class called
NativeUpsert. Which can then safely be removed. Maybe I am missing something? If so, then please explain? For now, back to RTBC. Thank you @alexpott for thinking about a BC layer.Comment #28
alexpottAh that's what I missed. From the fallback - so yeah there will be one unused class in the db driver. But that doesn't matter.
Committed 50a5a16 and pushed to 9.1.x. Thanks!
Comment #30
amateescu commentedComment #31
amateescu commented