Skip to content
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

[BUGFIX] Ensure correct default value normalization #901

Closed
TYPO3IncTeam opened this issue Apr 16, 2024 · 1 comment
Closed

[BUGFIX] Ensure correct default value normalization #901

TYPO3IncTeam opened this issue Apr 16, 2024 · 1 comment
Assignees
Labels

Comments

@TYPO3IncTeam
Copy link
Collaborator

ℹ️ View this commit on Github
👥 Authored by Stefan Bürk stefan@buerk.tech
✔️ Merged by Stefan Bürk stefan@buerk.tech

Commit message

[BUGFIX] Ensure correct default value normalization

Default value support for TEXT, JSON and BLOB fields
has been added with #103578 by implementing the use
of default value expression for MySQL. That required
to add custom normalization on data schema reads to
be comparable.

MySQL requires to use a single-quote to quote a single
quote in a value string, and due to the expression way
this needs to be properly decoded now in two steps:

  • Revert escape sequences in the retrieved default value
  • Unquote the unescaped retrieved default value

JSON field defaults shows a similar issue for double
quotes in the json value and can be fixed in the same
way.

Added test revealed, that Doctrine DBAL has an issue
with double single-quotes for PostgreSQL too. To fix
this the issue has been reported [1] and a pull-request
provided [2].

This change ensure correct unescaping and unquoting of
the retrieved column default value for TEXT, JSON and
BLOB column types for MySQL connections, enriched with
further tests.

The extended PostreSQLSchemaManager now clones method
_getPortableTableColumnDefinition() to incorporate
the bugfix directly until a fixed Doctrine DBAL version
has been released.

[1] doctrine/dbal#6357
[2] doctrine/dbal#6358

Resolves: #103610
Related: #103578
Releases: main
Change-Id: Icb39cdb8c87ae7907f84e5c38adcde4ef545ed1b
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/83745
Tested-by: Stefan Bürk stefan@buerk.tech
Tested-by: Garvin Hicking gh@faktor-e.de
Reviewed-by: Christian Kuhn lolli@schwarzbu.ch
Reviewed-by: Stefan Bürk stefan@buerk.tech
Reviewed-by: Garvin Hicking gh@faktor-e.de
Tested-by: core-ci typo3@b13.com
Tested-by: Christian Kuhn lolli@schwarzbu.ch

➗ Modified files

13.1/Feature-103578-AddDatabaseDefaultValueSupportForTEXTBLOBAndJSONFieldTypes.rst
@@ -43,6 +43,21 @@ Example
         ]
     );
 
+Advanced example with value quoting
+-----------------------------------
+
+..  code-block:: sql
+    :caption: EXT:my_extension/ext_tables.sql
+
+    CREATE TABLE a_textfield_test_table
+    (
+        # JSON object default value containting single quote in json field
+        field1 JSON NOT NULL DEFAULT '{"key1": "value1", "key2": 123, "key3": "value with a '' single quote"}',
+
+        # JSON object default value containing double-quote in json field
+        field2 JSON NOT NULL DEFAULT '{"key1": "value1", "key2": 123, "key3": "value with a \" double quote"}',
+    );
+
 Impact
 ======
 
@linawolf
Copy link
Member

linawolf commented Sep 9, 2024

According to stefan bürk you should not rely on these. No need to document.

@linawolf linawolf closed this as completed Sep 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants