- Issue created by @lauriii
- Status changed to Needs review
over 1 year ago 11:52am 3 June 2023 - last update
over 1 year ago Custom Commands Failed - last update
over 1 year ago Custom Commands Failed - last update
over 1 year ago 29,411 pass - last update
over 1 year ago 29,409 pass, 1 fail - last update
over 1 year ago 29,411 pass - last update
over 1 year ago 29,410 pass, 1 fail - last update
over 1 year ago 29,411 pass - Status changed to RTBC
over 1 year ago 11:22pm 3 June 2023 - 🇺🇸United States smustgrave
Tests all green.
Question if this needs a test or not?
- Status changed to Needs review
over 1 year ago 1:46pm 4 June 2023 - last update
over 1 year ago 29,412 pass - 🇫🇮Finland lauriii Finland
Renamed the new join plugin to
casted_int_field_join
which should describe the plugin a bit better. I also added kernel tests for the plugin. The file tests already cover this from integration standpoint. - last update
over 1 year ago 29,412 pass 6:07 5:28 Running- Status changed to Needs work
over 1 year ago 3:28pm 4 June 2023 - 🇺🇸United States phenaproxima Massachusetts
@lauriii explained this to me at DrupalCon. It makes sense to me, and although it's awkward, its awkwardness comes from the fact that a lot of what Views does is awkward.
So, the code things that jumped out at me:
-
+++ b/core/modules/views/src/Plugin/views/join/CastedIntFieldJoin.php @@ -0,0 +1,74 @@ + switch (\Drupal::database()->databaseType()) { + case 'mysql': + $cast_data_type = 'UNSIGNED'; + break; + + default: + $cast_data_type = 'INTEGER'; + break; + }
Can this be a match expression?
-
+++ b/core/modules/views/src/Plugin/views/join/CastedIntFieldJoin.php @@ -0,0 +1,74 @@ + switch ($this->configuration['cast'] ?? 'right') { + case 'left': + $left_field = "CAST($left_field AS $cast_data_type)"; + break; + + case 'right': + $right_field = "CAST($right_field AS $cast_data_type)"; + break; + }
This should be a match expression so that it's not possible to pass in an invalid value for
cast
. -
+++ b/core/modules/views/tests/src/Kernel/Plugin/CastedIntFieldJoinTest.php @@ -0,0 +1,178 @@ + * A plugin manager which handlers the instances of joins.
s/handlers/handles
-
+++ b/core/modules/views/tests/src/Kernel/Plugin/CastedIntFieldJoinTest.php @@ -0,0 +1,178 @@ + if ($connection->databaseType() === 'mysql') { + $this->assertStringContainsString('views_test_data.uid = CAST(users4.uid AS UNSIGNED)', $join_info['condition']); + } + else { + $this->assertStringContainsString('views_test_data.uid = CAST(users4.uid AS INTEGER)', $join_info['condition']); + }
IMHO we could do this:
$this->assertStringStartsWith('views_test_data.uid = CAST(users4.uid AS ', $join_info['condition']); if ($connection->databaseType() === 'mysql') { $this->assertStringEndsWith('UNSIGNED)', $join_info['condition']); } else { $this->assertStringEndsWith('INTEGER)', $join_info['condition']); }
-
- Status changed to Needs review
over 1 year ago 5:17pm 4 June 2023 - last update
over 1 year ago 29,412 pass - 🇫🇮Finland lauriii Finland
- 🇮🇹Italy mondrake 🇮🇹
Please do not hardcode SQL depending on the database type. It fails database abstraction and makes it hard for contrib database drivers to try and keep up. Backend-overrideable services were introduced for this purpose. As a reference, see the data management functions.
- Status changed to RTBC
over 1 year ago 6:04pm 4 June 2023 - 🇺🇸United States cosmicdreams Minneapolis/St. Paul
Haven't manually tested this one but the code looks good.
- Status changed to Needs work
over 1 year ago 6:05pm 4 June 2023 - 🇺🇸United States cosmicdreams Minneapolis/St. Paul
Laurii's sitting right here though and wants to get @mondrake's change in.
- Status changed to Needs review
over 1 year ago 8:11pm 4 June 2023 - last update
over 1 year ago 29,412 pass - 🇫🇮Finland lauriii Finland
@mondrake I wasn't sure if it was required for the Views plugins since there were already couple Views plugins depending on database type directly. Happy to implement that though 👍
- last update
over 1 year ago 29,412 pass - last update
over 1 year ago 29,412 pass - last update
over 1 year ago Custom Commands Failed - last update
over 1 year ago Custom Commands Failed - last update
over 1 year ago Custom Commands Failed - last update
over 1 year ago 29,412 pass - last update
over 1 year ago 29,411 pass, 1 fail - last update
over 1 year ago 29,412 pass - last update
over 1 year ago 29,412 pass - last update
over 1 year ago 29,417 pass - last update
over 1 year ago 29,417 pass - last update
over 1 year ago 29,417 pass - Status changed to RTBC
over 1 year ago 5:32pm 5 June 2023 - 🇺🇸United States smustgrave
All green so assuming it's good as it's fixing a test case.
- last update
over 1 year ago 29,421 pass - last update
over 1 year ago 29,437 pass - last update
over 1 year ago 29,438 pass 57:38 56:21 Running- last update
over 1 year ago 29,451 pass - last update
over 1 year ago 29,500 pass - Open on Drupal.org →Environment: PHP 8.2 & MySQL 8last update
over 1 year ago Waiting for branch to pass - last update
over 1 year ago 29,509 pass - last update
over 1 year ago 29,554 pass - last update
over 1 year ago 29,554 pass 57:38 53:23 Running- last update
over 1 year ago 29,568 pass - last update
over 1 year ago 29,572 pass - last update
over 1 year ago 29,802 pass - last update
over 1 year ago 29,802 pass - last update
over 1 year ago 29,803 pass - last update
over 1 year ago 29,805 pass - last update
over 1 year ago 29,812 pass - last update
over 1 year ago 29,815 pass - last update
over 1 year ago 29,816 pass - last update
over 1 year ago 29,816 pass 42:39 20:57 Running- Status changed to Needs work
over 1 year ago 8:37am 22 July 2023 - 🇳🇱Netherlands daffie
-
+++ b/core/modules/views/src/Plugin/views/join/CastedIntFieldJoin.php @@ -0,0 +1,65 @@ + switch ($this->configuration['cast'] ?? 'right') { + case 'left': + $left_field = \Drupal::service('views.cast_sql')->getFieldAsInt($left_field); + break; + + case 'right': + $right_field = \Drupal::service('views.cast_sql')->getFieldAsInt($right_field); + break; + }
Are there more possibilities then 'left' or 'right'? if not can we do a simple if-statement?
-
+++ b/core/modules/views/src/Plugin/views/query/CastSqlInterface.php --- /dev/null +++ b/core/modules/views/src/Plugin/views/query/MysqlCastSql.php +++ b/core/modules/views/src/Plugin/views/query/MysqlCastSql.php --- /dev/null +++ b/core/modules/views/src/Plugin/views/query/PostgresqlCastSql.php +++ b/core/modules/views/src/Plugin/views/query/PostgresqlCastSql.php --- /dev/null +++ b/core/modules/views/src/Plugin/views/query/SqliteCastSql.php +++ b/core/modules/views/views.services.yml @@ -95,3 +95,13 @@ services: + pgsql.views.cast_sql: + class: Drupal\views\Plugin\views\query\PostgresqlCastSql + public: false + sqlite.views.cast_sql: + class: Drupal\views\Plugin\views\query\SqliteCastSql + public: false
Can we move these plugins to the database modules. This make it easier for contrib database driver to do the same.
-
+++ b/core/modules/views/tests/src/Kernel/Plugin/CastedIntFieldJoinTest.php @@ -0,0 +1,167 @@ +class CastedIntFieldJoinTest extends RelationshipJoinTestBase {
This test has database specific testing. Can we move the database specific parts to the database modules. This allows contrib database modules to do the same. See: core/tests/Drupal/KernelTests/Core/Database/DriverSpecificKernelTestBase.php
-
- 🇪🇸Spain penyaskito Seville 💃, Spain 🇪🇸, UTC+2 🇪🇺
> Can we move these plugins to the database modules. This make it easier for contrib database driver to do the same.
Even if most use mysql, mysql is the one which require a different behavior. So discussed with @lendude, @lauriii and @longwave and we agree that it makes the most sense to have PostgreSQL/SQLite as the default behavior, and override for MySQL, so we skip the overrides and hopefully other implementations like MSSql won't need to override it. Patch coming shortly.
- Status changed to Needs review
over 1 year ago 3:21pm 22 July 2023 - last update
over 1 year ago 29,881 pass - 🇪🇸Spain penyaskito Seville 💃, Spain 🇪🇸, UTC+2 🇪🇺
- last update
over 1 year ago 29,870 pass, 2 fail - last update
over 1 year ago 29,881 pass - last update
over 1 year ago 29,881 pass - last update
over 1 year ago 29,882 pass, 2 fail - 🇪🇸Spain penyaskito Seville 💃, Spain 🇪🇸, UTC+2 🇪🇺
Changed switch to a simpler if-else. Added test per db engine as requested in #17.
- last update
over 1 year ago 29,882 pass, 2 fail - last update
over 1 year ago 29,882 pass, 2 fail The last submitted patch, 21: 3364621--21.patch, failed testing. View results →
- last update
over 1 year ago 29,883 pass, 1 fail - 🇪🇸Spain penyaskito Seville 💃, Spain 🇪🇸, UTC+2 🇪🇺
Fixed namespace. Not sure if I need to move the abstract test class?
- last update
over 1 year ago 29,881 pass, 1 fail - last update
over 1 year ago 29,881 pass, 1 fail The last submitted patch, 23: 3364621--23.patch, failed testing. View results →
- last update
over 1 year ago Custom Commands Failed - 🇪🇸Spain penyaskito Seville 💃, Spain 🇪🇸, UTC+2 🇪🇺
Renamed to *TestBase as apparently I can't have an abstract Test.
- last update
over 1 year ago Custom Commands Failed - last update
over 1 year ago Custom Commands Failed - last update
over 1 year ago Custom Commands Failed - 🇪🇸Spain penyaskito Seville 💃, Spain 🇪🇸, UTC+2 🇪🇺
Need to catch up on sleep when I'm home definitely.
- last update
over 1 year ago Custom Commands Failed - last update
over 1 year ago Custom Commands Failed - last update
over 1 year ago 29,882 pass - 🇪🇸Spain penyaskito Seville 💃, Spain 🇪🇸, UTC+2 🇪🇺
fixed phpstan complaints.
- last update
over 1 year ago 29,882 pass - last update
over 1 year ago 29,882 pass - Status changed to Needs work
over 1 year ago 9:29am 23 July 2023 - 🇳🇱Netherlands daffie
+++ b/core/modules/views/tests/src/Kernel/Plugin/CastedIntFieldJoinTestBase.php @@ -0,0 +1,203 @@ + $cast_type = match ($connection->databaseType()) { + 'mysql' => 'UNSIGNED', + default => 'INTEGER', + };
The idea with database specific testing is that we put the database specific stuff in the database override of the test. My suggestion would be to a class variable called something like "casting_type". The default value would be "INTEGER". The MySQL test will override it and set the value to "UNSIGNED".
@penyaskito: The patch look great! Just 1 minor point.
- Status changed to Needs review
over 1 year ago 10:23pm 23 July 2023 - last update
over 1 year ago 29,882 pass - 🇪🇸Spain penyaskito Seville 💃, Spain 🇪🇸, UTC+2 🇪🇺
My train of thought was that this might not be enough for some engines and they will end up needing to override the complete test.
But let's do that anyway and if that's needed we will figure out later. - last update
over 1 year ago 29,882 pass - last update
over 1 year ago 29,882 pass - Status changed to RTBC
over 1 year ago 7:07am 24 July 2023 - 🇬🇧United Kingdom catch
OK this is very tricky but I see why it's necessary...
Can we open a follow-up to potentially remove this handling once 🌱 Add a reliable entity-usage system to core Active is complete (or more specifically, once the file_usage table is gone)? I'm slightly concerned that if file_usage is the only use-case, we might end up maintaining it forever once that's eventually gone. Having said that there might be similar schemas in contrib that also break now that this would fix.
- 🇫🇮Finland lauriii Finland
Agreed that we should be able to get rid of this once 🌱 Add a reliable entity-usage system to core Active is done. Opened follow-up: 📌 [PP-1] Deprecate and remove Drupal\views\Plugin\views\join\CastedIntFieldJoin Postponed .
- last update
over 1 year ago 29,885 pass - last update
over 1 year ago 29,889 pass - last update
over 1 year ago 29,912 pass - last update
over 1 year ago 29,915 pass - last update
over 1 year ago 29,950 pass - last update
over 1 year ago 29,957 pass - last update
over 1 year ago 29,957 pass - last update
over 1 year ago 29,962 pass - last update
over 1 year ago 29,962 pass - last update
over 1 year ago 29,962 pass - last update
over 1 year ago 29,963 pass - Status changed to Fixed
over 1 year ago 8:38pm 16 August 2023 -
longwave →
committed 6e8cab81 on 11.x
Issue #3364621 by lauriii, penyaskito, daffie, catch, phenaproxima,...
-
longwave →
committed 6e8cab81 on 11.x
Automatically closed - issue fixed for 2 weeks with no activity.