-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
MariaDB 10.3 Native JSON Support #3202
Comments
I think it makes sense. If you're going to file a pull request, please make sure there's a functional test which creates and uses a JSON column. This way, we'll make sure that all platforms which declare JSON as supported actually support it. |
with
on
I'm seeing similar issues to those previously reported (& solved) for MDB 10.2x here
Particularly, the 'infinite schema updates' and failing
after a (reported) 'successful'
Other than the common issue of 'MDB 10.3 support', not clear that this is the right place for this. If so, and it's useful, I can add the details here on request. Atm, I've no specific functional test, other than a new DB init on a symfony4 project install. |
@hal869 please provide the details. |
On a new SF4 + phpcr project, after package installs, starting with new/clean DBs mysqlshow ...
a phpcr DB init reports successful completion
mysqlshow ...
where tail -f mariadb.log
then a general migration diff
tail -f mariadb.log
and the migrate
tail -f mariadb.log
next, validate fails
tail -f mariadb.log
and checking for the issue
ad infinitum ... |
@hal869 and what's the entity mapping? Also, as we always ask, could you try to isolate the issue in a test case? |
@lcobucci After our offline chat, working on test case, came across this: and related ... Updated to latest dbal/symfony/mariadb, and explicitly removed the
letting the version returned from mariadb get used. which seems to do the trick for the :validate,
now, to look further downstream ... |
What's the status of this feature? What has to be done in order to get native JSON support for MariaDB? I've tried to test it by creating a platform class (by extending I've never contributed to Doctrine before, but let me know if I can help. |
@stephanvierkant all you can see here is the status. There's nothing happening in this regard behind the curtain.
It looks like an exception. All other platform classes are not
Please submit a pull request. |
As stated in the MariaDB documentation, the So maybe that behavior could be kept for later MariaDB versions by using this alias? (I'm on 10.3 and setting the |
I did stumble over this today. As I think it could be a bc break changing: dbal/src/Platforms/MariaDb1027Platform.php Lines 20 to 23 in ebd986b
from |
Seems like this was changed in #2825 but I'm not understanding why not let MariaDB handle this? |
@alexander-schranz I think a platform option would be more appropriate. See for instance dbal/src/Platforms/PostgreSQLPlatform.php Lines 1217 to 1224 in 2aec3f8
Maybe it was simply overlooked? |
Not sure 🙈. @lcobucci Do you remember why the JSON type was changed to TEXT again in: #2825 (comment)? |
It's been a while but it was to reflect the reality (JSON is just an alias): https://mariadb.com/kb/en/json-data-type/ I'd advise to send a PR proposing a fix and see what happens on the suite now. |
To @lcobucci's point, given the behavior documented in #5100 (comment), I'd say that MariaDB 10.3 does not natively support JSON. And assuming their reasoning:
It won't support it in the near future. There is a possibility to improve JSON support in MariaDB by adding |
@morozov they support it in there way by having a JSON alias to LONGTEXT and JSON fields automatically gets a |
It doesn't look like they do, nor that it's stated in the documentation:
The DBAL would have to add this check automatically and then check if it exists during the introspection. |
@morozov it says in the reasoning you linked that this behavior is supported since version 10.4.3 and it looks like you used 10.3 in the provided logs |
Yeah, it looks like it adds the constraint automatically on the newer versions:
|
MariaDb aliases columns specified as JSON to LONGTEXT. Since version 10.4.3, MariaDb adds a CHECK constraint to JSON columns to ensure they contain valid JSON and sets the column collation to utf8mb4_bin. Simply setting JSON as the column type in the platform results in introspection failures as the database reports LONGTEXT (not JSON) with changed collation. Therefore, inverse the aliasing where the relevant check constraint exists and ignore collation changes for JSON columns in the relevant database versions. The modified methods are MariaDBPlatform->getListTableColumnsSQL() and MySQLSchemaManager->selectTableColumns() The changes have been implemented in the MariaDBPlatform (guarded by a check for JSON as column type so they do not affect MariaDB1027Platform) and MySQLSchemaManager (guarded by a platform test). It ought to be possible to push most of the platform changes into the MySQLPlatform given the SQL query changes are guarded by MariaDB specific executable comments and so should be a no op for MySQL. Doing so would allow getDatabaseNameSQL() to be kept private. However, because the changes are entirely MariaDb specific they have been made in the MariaDBPlatform (this is also consistent with the plan to separate MariaDb and MySQL platforms). MariaDb1043Platform extends MariaDb1027Platform rather than MariaDBPlatform to ensure the platform checks in MySQLSchemaManager (based on MariaDb1027Platform) continue to work as expected. The alternative approach of adding the CHECK constraint to the SQL for the column is not robust as MariaDb syntax seems to require the CHECK constraint to be the final part of the column declaration and it was not obvious how to guarantee this (specifically, appending the CHECK constraint to the output of getJsonTypeDeclarationSQL() did not work). New public methods: MariaDBPlatform->getInverseJsonToLongtextAliasSQL() generates SQL snippets to inverse the JSON to LONGTEXT aliasing for JSON-specified columns. It is marked public because it is used in MySQLSchemaManager. Overridden methods: MariaDb1043Platform->getJsonTypeDeclarationSQL(). To return JSON. MariaDBPlatform->getListTableColumnsSQL(). To reverse the JSON to LONGTEXT aliasing carried out by MariaDb. MariaDBPlatform->MariaDBColumnToArray(). To unset collation and charset in column array (so parent needed to be marked protected). New test cases: 1. Types/JsonTest. Test storage and retrieval of json data. 2. Platforms/MariaDb1043PlatformTest. A clone of MariaDb1027Platform test. 3. Schema/MySQLSchemaManagerTest->testColumnIntrospection(). Ensures introspected table matches original table. Tests all doctrine types not just json. Based on failure highlighted in pull request doctrine#5100. For previous discussion on this topic, see: doctrine#5100 doctrine#3202 Further background at: https://mariadb.com/kb/en/json-data-type/ https://mariadb.com/kb/en/information-schema-check_constraints-table/ https://jira.mariadb.org/browse/MDEV-13916
MariaDb aliases columns specified as JSON to LONGTEXT. Since version 10.4.3, MariaDb adds a CHECK constraint to JSON columns to ensure they contain valid JSON and sets the column collation to utf8mb4_bin. Simply setting JSON as the column type in the platform results in introspection failures as the database reports LONGTEXT (not JSON) with changed collation. Therefore, inverse the aliasing where the relevant check constraint exists and ignore collation changes for JSON columns in the relevant database versions. The modified methods are MariaDBPlatform->getListTableColumnsSQL() and MySQLSchemaManager->selectTableColumns() The changes have been implemented in the MariaDBPlatform (guarded by a check for JSON as column type so they do not affect MariaDB1027Platform) and MySQLSchemaManager (guarded by a platform test). It ought to be possible to push most of the platform changes into the MySQLPlatform given the SQL query changes are guarded by MariaDB specific executable comments and so should be a no op for MySQL. Doing so would allow getDatabaseNameSQL() to be kept private. However, because the changes are entirely MariaDb specific they have been made in the MariaDBPlatform (this is also consistent with the plan to separate MariaDb and MySQL platforms). MariaDb1043Platform extends MariaDb1027Platform rather than MariaDBPlatform to ensure the platform checks in MySQLSchemaManager (based on MariaDb1027Platform) continue to work as expected. The alternative approach of adding the CHECK constraint to the SQL for the column is not robust as MariaDb syntax seems to require the CHECK constraint to be the final part of the column declaration and it was not obvious how to guarantee this (specifically, appending the CHECK constraint to the output of getJsonTypeDeclarationSQL() did not work). New public methods: MariaDBPlatform->getInverseJsonToLongtextAliasSQL() generates SQL snippets to inverse the JSON to LONGTEXT aliasing for JSON-specified columns. It is marked public because it is used in MySQLSchemaManager. Overridden methods: MariaDb1043Platform->getJsonTypeDeclarationSQL(). To return JSON. MariaDBPlatform->getListTableColumnsSQL(). To reverse the JSON to LONGTEXT aliasing carried out by MariaDb. MariaDBPlatform->MariaDBColumnToArray(). To unset collation and charset in column array (so parent needed to be marked protected). New test cases: 1. Types/JsonTest. Test storage and retrieval of json data. 2. Platforms/MariaDb1043PlatformTest. A clone of MariaDb1027Platform test. 3. Schema/MySQLSchemaManagerTest->testColumnIntrospection(). Ensures introspected table matches original table. Tests all doctrine types not just json. Based on failure highlighted in pull request doctrine#5100. For previous discussion on this topic, see: doctrine#5100 doctrine#3202 Further background at: https://mariadb.com/kb/en/json-data-type/ https://mariadb.com/kb/en/information-schema-check_constraints-table/ https://jira.mariadb.org/browse/MDEV-13916
MariaDb aliases columns specified as JSON to LONGTEXT. Since version 10.4.3, MariaDb adds a CHECK constraint to JSON columns to ensure they contain valid JSON and sets the column collation to utf8mb4_bin. Simply setting JSON as the column type in the platform results in introspection failures as the database reports LONGTEXT (not JSON) with changed collation. Therefore, inverse the aliasing where the relevant check constraint exists and ignore collation changes for JSON columns in the relevant database versions. The modified methods are MariaDBPlatform->getListTableColumnsSQL() and MySQLSchemaManager->selectTableColumns() The changes have been implemented in the MariaDBPlatform (guarded by a check for JSON as column type so they do not affect MariaDB1027Platform) and MySQLSchemaManager (guarded by a platform test). It ought to be possible to push most of the platform changes into the MySQLPlatform given the SQL query changes are guarded by MariaDB specific executable comments and so should be a no op for MySQL. Doing so would allow getDatabaseNameSQL() to be kept private. However, because the changes are entirely MariaDb specific they have been made in the MariaDBPlatform (this is also consistent with the plan to separate MariaDb and MySQL platforms). MariaDb1043Platform extends MariaDb1027Platform rather than MariaDBPlatform to ensure the platform checks in MySQLSchemaManager (based on MariaDb1027Platform) continue to work as expected. The alternative approach of adding the CHECK constraint to the SQL for the column is not robust as MariaDb syntax seems to require the CHECK constraint to be the final part of the column declaration and it was not obvious how to guarantee this (specifically, appending the CHECK constraint to the output of getJsonTypeDeclarationSQL() did not work). New public methods: MariaDBPlatform->getInverseJsonToLongtextAliasSQL() generates SQL snippets to inverse the JSON to LONGTEXT aliasing for JSON-specified columns. It is marked public because it is used in MySQLSchemaManager. Overridden methods: MariaDb1043Platform->getJsonTypeDeclarationSQL(). To return JSON. MariaDBPlatform->getListTableColumnsSQL(). To reverse the JSON to LONGTEXT aliasing carried out by MariaDb. MariaDBPlatform->MariaDBColumnToArray(). To unset collation and charset in column array (so parent needed to be marked protected). New test cases: 1. Types/JsonTest. Test storage and retrieval of json data. 2. Platforms/MariaDb1043PlatformTest. A clone of MariaDb1027Platform test. 3. Schema/MySQLSchemaManagerTest->testColumnIntrospection(). Ensures introspected table matches original table. Tests all doctrine types not just json. Based on failure highlighted in pull request doctrine#5100. For previous discussion on this topic, see: doctrine#5100 doctrine#3202 Further background at: https://mariadb.com/kb/en/json-data-type/ https://mariadb.com/kb/en/information-schema-check_constraints-table/ https://jira.mariadb.org/browse/MDEV-13916 v2 of JsonTest.php: 1. Simplify array shapes of json structures. 2. Deal with json returned as a stream not string. It seems Oracle 11 returns json as a stream so convert streams to strings.
MariaDb aliases columns specified as JSON to LONGTEXT. Since version 10.4.3, MariaDb adds a CHECK constraint to JSON columns to ensure they contain valid JSON and sets the column collation to utf8mb4_bin. Simply setting JSON as the column type in the platform results in introspection failures as the database reports LONGTEXT (not JSON) with changed collation. Therefore, inverse the aliasing where the relevant check constraint exists and ignore collation changes for JSON columns in the relevant database versions. The modified methods are MariaDBPlatform->getListTableColumnsSQL() and MySQLSchemaManager->selectTableColumns() The changes have been implemented in the MariaDBPlatform (guarded by a check for JSON as column type so they do not affect MariaDB1027Platform) and MySQLSchemaManager (guarded by a platform test). It ought to be possible to push most of the platform changes into the MySQLPlatform given the SQL query changes are guarded by MariaDB specific executable comments and so should be a no op for MySQL. Doing so would allow getDatabaseNameSQL() to be kept private. However, because the changes are entirely MariaDb specific they have been made in the MariaDBPlatform (this is also consistent with the plan to separate MariaDb and MySQL platforms). MariaDb1043Platform extends MariaDb1027Platform rather than MariaDBPlatform to ensure the platform checks in MySQLSchemaManager (based on MariaDb1027Platform) continue to work as expected. The alternative approach of adding the CHECK constraint to the SQL for the column is not robust as MariaDb syntax seems to require the CHECK constraint to be the final part of the column declaration and it was not obvious how to guarantee this (specifically, appending the CHECK constraint to the output of getJsonTypeDeclarationSQL() did not work). New public methods: MariaDBPlatform->getInverseJsonToLongtextAliasSQL() generates SQL snippets to inverse the JSON to LONGTEXT aliasing for JSON-specified columns. It is marked public because it is used in MySQLSchemaManager. Overridden methods: MariaDb1043Platform->getJsonTypeDeclarationSQL(). To return JSON. MariaDBPlatform->getListTableColumnsSQL(). To reverse the JSON to LONGTEXT aliasing carried out by MariaDb. MariaDBPlatform->MariaDBColumnToArray(). To unset collation and charset in column array (so parent needed to be marked protected). New test cases: 1. Types/JsonTest. Test storage and retrieval of json data. 2. Platforms/MariaDb1043PlatformTest. A clone of MariaDb1027Platform test. 3. Schema/MySQLSchemaManagerTest->testColumnIntrospection(). Ensures introspected table matches original table. Tests all doctrine types not just json. Based on failure highlighted in pull request doctrine#5100. For previous discussion on this topic, see: doctrine#5100 doctrine#3202 Further background at: https://mariadb.com/kb/en/json-data-type/ https://mariadb.com/kb/en/information-schema-check_constraints-table/ https://jira.mariadb.org/browse/MDEV-13916 v2 JsonTest.php: 1. Simplify array shapes of json structures. 2. Deal with json returned as a stream not string. It seems Oracle 11 returns json as a stream so convert streams to strings. v3 JsonTest.php: 1. 'json_table' is a reserved word in MySQL (and a function name in Oracle SQL). Use json_test_table instead. 2. Some databases e.g. MySQL reorder json arrays so the insert order will not necessarily match the select order. Resort the arrays before testing for equality. MySQLSchemaManager.php: Remove 'instanceof MariaDb1027Platform' test as follows: a. Add getColumnTypeSQLSnippets() method to AbstractMySQLPlatform which returns the default snippets for all databases except MariaDb. b. Override the method in MariDBPlatform to return the SQL snippets which inverse the JSON to LONGTEXT aliasing. Note that the getColumnTypeSQLSnippets() method in MariaDBPlatform was previously called getInverseJsonToLongtextAliasSQL() and was renamed to make more sense for MySQL platforms in general.
MariaDb aliases columns specified as JSON to LONGTEXT. Since version 10.4.3, MariaDb adds a CHECK constraint to JSON columns to ensure they contain valid JSON and sets the column collation to utf8mb4_bin. Simply setting JSON as the column type in the platform results in introspection failures as the database reports LONGTEXT (not JSON) with changed collation. Therefore, inverse the aliasing where the relevant check constraint exists and ignore collation changes for JSON columns in the relevant database versions. The modified methods are MariaDBPlatform->getListTableColumnsSQL() and MySQLSchemaManager->selectTableColumns() The changes have been implemented in the MariaDBPlatform (guarded by a check for JSON as column type so they do not affect MariaDB1027Platform) and MySQLSchemaManager (guarded by a platform test). It ought to be possible to push most of the platform changes into the MySQLPlatform given the SQL query changes are guarded by MariaDB specific executable comments and so should be a no op for MySQL. Doing so would allow getDatabaseNameSQL() to be kept private. However, because the changes are entirely MariaDb specific they have been made in the MariaDBPlatform (this is also consistent with the plan to separate MariaDb and MySQL platforms). MariaDb1043Platform extends MariaDb1027Platform rather than MariaDBPlatform to ensure the platform checks in MySQLSchemaManager (based on MariaDb1027Platform) continue to work as expected. The alternative approach of adding the CHECK constraint to the SQL for the column is not robust as MariaDb syntax seems to require the CHECK constraint to be the final part of the column declaration and it was not obvious how to guarantee this (specifically, appending the CHECK constraint to the output of getJsonTypeDeclarationSQL() did not work). New public methods: MariaDBPlatform->getInverseJsonToLongtextAliasSQL() generates SQL snippets to inverse the JSON to LONGTEXT aliasing for JSON-specified columns. It is marked public because it is used in MySQLSchemaManager. Overridden methods: MariaDb1043Platform->getJsonTypeDeclarationSQL(). To return JSON. MariaDBPlatform->getListTableColumnsSQL(). To reverse the JSON to LONGTEXT aliasing carried out by MariaDb. MariaDBPlatform->MariaDBColumnToArray(). To unset collation and charset in column array (so parent needed to be marked protected). New test cases: 1. Types/JsonTest. Test storage and retrieval of json data. 2. Platforms/MariaDb1043PlatformTest. A clone of MariaDb1027Platform test. 3. Schema/MySQLSchemaManagerTest->testColumnIntrospection(). Ensures introspected table matches original table. Tests all doctrine types not just json. Based on failure highlighted in pull request doctrine#5100. For previous discussion on this topic, see: doctrine#5100 doctrine#3202 Further background at: https://mariadb.com/kb/en/json-data-type/ https://mariadb.com/kb/en/information-schema-check_constraints-table/ https://jira.mariadb.org/browse/MDEV-13916 v2 JsonTest.php: 1. Simplify array shapes of json structures. 2. Deal with json returned as a stream not string. It seems Oracle 11 returns json as a stream so convert streams to strings. v3 JsonTest.php: 1. 'json_table' is a reserved word in MySQL (and a function name in Oracle SQL). Use json_test_table instead. 2. Some databases e.g. MySQL reorder json arrays so the insert order will not necessarily match the select order. Resort the arrays before testing for equality. MySQLSchemaManager.php: Remove 'instanceof MariaDb1027Platform' test as follows: a. Add getColumnTypeSQLSnippets() method to AbstractMySQLPlatform which returns the default snippets for all databases except MariaDb. b. Override the method in MariDBPlatform to return the SQL snippets which inverse the JSON to LONGTEXT aliasing. Note that the getColumnTypeSQLSnippets() method in MariaDBPlatform was previously called getInverseJsonToLongtextAliasSQL() and was renamed to make more sense for MySQL platforms in general.
MariaDb aliases columns specified as JSON to LONGTEXT. Since version 10.4.3, MariaDb adds a CHECK constraint to JSON columns to ensure they contain valid JSON and sets the column collation to utf8mb4_bin. Simply setting JSON as the column type in the platform results in introspection failures as the database reports LONGTEXT (not JSON) with changed collation. Therefore, inverse the aliasing where the relevant check constraint exists and ignore collation changes for JSON columns in the relevant database versions. The modified methods are MariaDBPlatform->getListTableColumnsSQL() and MySQLSchemaManager->selectTableColumns() The changes have been implemented in the MariaDBPlatform (guarded by a check for JSON as column type so they do not affect MariaDB1027Platform) and MySQLSchemaManager (guarded by a platform test). It ought to be possible to push most of the platform changes into the MySQLPlatform given the SQL query changes are guarded by MariaDB specific executable comments and so should be a no op for MySQL. Doing so would allow getDatabaseNameSQL() to be kept private. However, because the changes are entirely MariaDb specific they have been made in the MariaDBPlatform (this is also consistent with the plan to separate MariaDb and MySQL platforms). MariaDb1043Platform extends MariaDb1027Platform rather than MariaDBPlatform to ensure the platform checks in MySQLSchemaManager (based on MariaDb1027Platform) continue to work as expected. The alternative approach of adding the CHECK constraint to the SQL for the column is not robust as MariaDb syntax seems to require the CHECK constraint to be the final part of the column declaration and it was not obvious how to guarantee this (specifically, appending the CHECK constraint to the output of getJsonTypeDeclarationSQL() did not work). New public methods: MariaDBPlatform->getInverseJsonToLongtextAliasSQL() generates SQL snippets to inverse the JSON to LONGTEXT aliasing for JSON-specified columns. It is marked public because it is used in MySQLSchemaManager. Overridden methods: MariaDb1043Platform->getJsonTypeDeclarationSQL(). To return JSON. MariaDBPlatform->getListTableColumnsSQL(). To reverse the JSON to LONGTEXT aliasing carried out by MariaDb. MariaDBPlatform->MariaDBColumnToArray(). To unset collation and charset in column array (so parent needed to be marked protected). New test cases: 1. Types/JsonTest. Test storage and retrieval of json data. 2. Platforms/MariaDb1043PlatformTest. A clone of MariaDb1027Platform test. 3. Schema/MySQLSchemaManagerTest->testColumnIntrospection(). Ensures introspected table matches original table. Tests all doctrine types not just json. Based on failure highlighted in pull request doctrine#5100. For previous discussion on this topic, see: doctrine#5100 doctrine#3202 Further background at: https://mariadb.com/kb/en/json-data-type/ https://mariadb.com/kb/en/information-schema-check_constraints-table/ https://jira.mariadb.org/browse/MDEV-13916 v2 JsonTest.php: 1. Simplify array shapes of json structures. 2. Deal with json returned as a stream not string. It seems Oracle 11 returns json as a stream so convert streams to strings. v3 JsonTest.php: 1. 'json_table' is a reserved word in MySQL (and a function name in Oracle SQL). Use json_test_table instead. 2. Some databases e.g. MySQL reorder json arrays so the insert order will not necessarily match the select order. Resort the arrays before testing for equality. MySQLSchemaManager.php: Remove 'instanceof MariaDb1027Platform' test as follows: a. Add getColumnTypeSQLSnippets() method to AbstractMySQLPlatform which returns the default snippets for all databases except MariaDb. b. Override the method in MariDBPlatform to return the SQL snippets which inverse the JSON to LONGTEXT aliasing. Note that the getColumnTypeSQLSnippets() method in MariaDBPlatform was previously called getInverseJsonToLongtextAliasSQL() and was renamed to make more sense for MySQL platforms in general.
MariaDb aliases columns specified as JSON to LONGTEXT. Since version 10.4.3, MariaDb adds a CHECK constraint to JSON columns to ensure they contain valid JSON and sets the column collation to utf8mb4_bin. Simply setting JSON as the column type in the platform results in introspection failures as the database reports LONGTEXT (not JSON) with changed collation. Therefore, inverse the aliasing where the relevant check constraint exists and ignore collation changes for JSON columns in the relevant database versions. The modified methods are MariaDBPlatform->getListTableColumnsSQL() and MySQLSchemaManager->selectTableColumns() The changes have been implemented in the MariaDBPlatform (guarded by a check for JSON as column type so they do not affect MariaDB1027Platform) and MySQLSchemaManager (guarded by a platform test). It ought to be possible to push most of the platform changes into the MySQLPlatform given the SQL query changes are guarded by MariaDB specific executable comments and so should be a no op for MySQL. Doing so would allow getDatabaseNameSQL() to be kept private. However, because the changes are entirely MariaDb specific they have been made in the MariaDBPlatform (this is also consistent with the plan to separate MariaDb and MySQL platforms). MariaDb1043Platform extends MariaDb1027Platform rather than MariaDBPlatform to ensure the platform checks in MySQLSchemaManager (based on MariaDb1027Platform) continue to work as expected. The alternative approach of adding the CHECK constraint to the SQL for the column is not robust as MariaDb syntax seems to require the CHECK constraint to be the final part of the column declaration and it was not obvious how to guarantee this (specifically, appending the CHECK constraint to the output of getJsonTypeDeclarationSQL() did not work). New public methods: MariaDBPlatform->getInverseJsonToLongtextAliasSQL() generates SQL snippets to inverse the JSON to LONGTEXT aliasing for JSON-specified columns. It is marked public because it is used in MySQLSchemaManager. Overridden methods: MariaDb1043Platform->getJsonTypeDeclarationSQL(). To return JSON. MariaDBPlatform->getListTableColumnsSQL(). To reverse the JSON to LONGTEXT aliasing carried out by MariaDb. MariaDBPlatform->MariaDBColumnToArray(). To unset collation and charset in column array (so parent needed to be marked protected). New test cases: 1. Types/JsonTest. Test storage and retrieval of json data. 2. Platforms/MariaDb1043PlatformTest. A clone of MariaDb1027Platform test. 3. Schema/MySQLSchemaManagerTest->testColumnIntrospection(). Ensures introspected table matches original table. Tests all doctrine types not just json. Based on failure highlighted in pull request doctrine#5100. For previous discussion on this topic, see: doctrine#5100 doctrine#3202 Further background at: https://mariadb.com/kb/en/json-data-type/ https://mariadb.com/kb/en/information-schema-check_constraints-table/ https://jira.mariadb.org/browse/MDEV-13916 v2 JsonTest.php: 1. Simplify array shapes of json structures. 2. Deal with json returned as a stream not string. It seems Oracle 11 returns json as a stream so convert streams to strings. v3 JsonTest.php: 1. 'json_table' is a reserved word in MySQL (and a function name in Oracle SQL). Use json_test_table instead. 2. Some databases e.g. MySQL reorder json arrays so the insert order will not necessarily match the select order. Resort the arrays before testing for equality. MySQLSchemaManager.php: Remove 'instanceof MariaDb1027Platform' test as follows: a. Add getColumnTypeSQLSnippets() method to AbstractMySQLPlatform which returns the default snippets for all databases except MariaDb. b. Override the method in MariDBPlatform to return the SQL snippets which inverse the JSON to LONGTEXT aliasing. Note that the getColumnTypeSQLSnippets() method in MariaDBPlatform was previously called getInverseJsonToLongtextAliasSQL() and was renamed to make more sense for MySQL platforms in general.
MariaDb aliases columns specified as JSON to LONGTEXT. Since version 10.4.3, MariaDb adds a CHECK constraint to JSON columns to ensure they contain valid JSON and sets the column collation to utf8mb4_bin. Simply setting JSON as the column type in the platform results in introspection failures as the database reports LONGTEXT (not JSON) with changed collation. Therefore, inverse the aliasing where the relevant check constraint exists and ignore collation changes for JSON columns in the relevant database versions. The main functional changes are in: - MariaDB1043Platform->getListTableColumnsSQL() and - MySQLSchemaManager->selectTableColumns() MariaDb1043Platform extends MariaDb1027Platform rather than MariaDBPlatform to ensure the platform checks in MySQLSchemaManager (based on MariaDb1027Platform) continue to work as expected. The alternative approach of adding the CHECK constraint to the SQL for the column is not robust as MariaDb syntax seems to require the CHECK constraint to be the final part of the column declaration and it was not obvious how to guarantee this (specifically, appending the CHECK constraint to the output of getJsonTypeDeclarationSQL() did not work). New public methods: MariaDBPlatform->getColumnTypeSQLSnippets() generates SQL snippets to reverse the JSON to LONGTEXT aliasing for JSON-specified columns. It is also used in MySQLSchemaManager. It still checks that json columns are JSON data type so that switching the getJsonTypeDeclarationSQL to LONGTEXT is all that is necessary to revert to old behaviour which is helpful for testing. Overridden methods in MariaDb1043Platform: MariaDb1043Platform->getJsonTypeDeclarationSQL(). To return JSON. MariaDBPlatform->getListTableColumnsSQL(). To reverse the JSON to LONGTEXT aliasing carried out by MariaDb. MariaDBPlatform->getColumnDeclarationSQL(). To unset collation and charset (used by the comparator). New test cases: 1. Types/JsonTest. Test storage and retrieval of json data. 2. Platforms/MariaDb1043PlatformTest. A clone of MariaDb1027Platform test. 3. Schema/MySQLSchemaManagerTest->testColumnIntrospection(). Ensures introspected table matches original table. Tests all doctrine types not just json. Based on failure highlighted in pull request doctrine#5100. For previous discussion on this topic, see: doctrine#5100 doctrine#3202 Further background at: https://mariadb.com/kb/en/json-data-type/ https://mariadb.com/kb/en/information-schema-check_constraints-table/ https://jira.mariadb.org/browse/MDEV-13916 Notes regarding JsonTest.php: 1. Some platforms return json as a stream so convert streams to strings. 2. 'json_table' is a reserved word in MySQL (and a function name in Oracle SQL). Use json_test_table instead. 3. Some platforms reorder json arrays so the insert order will not necessarily match the select order. Resort the arrays before testing for equality.
MariaDb aliases columns specified as JSON to LONGTEXT. Since version 10.4.3, MariaDb adds a CHECK constraint to JSON columns to ensure they contain valid JSON and sets the column collation to utf8mb4_bin. Simply setting JSON as the column type in the platform results in introspection failures as the database reports LONGTEXT (not JSON) with changed collation. Therefore, inverse the aliasing where the relevant check constraint exists and ignore collation changes for JSON columns in the relevant database versions. The main functional changes are in: - MariaDB1043Platform->getListTableColumnsSQL() and - MySQLSchemaManager->selectTableColumns() MariaDb1043Platform extends MariaDb1027Platform rather than MariaDBPlatform to ensure the platform checks in MySQLSchemaManager (based on MariaDb1027Platform) continue to work as expected. The alternative approach of adding the CHECK constraint to the SQL for the column is not robust as MariaDb syntax seems to require the CHECK constraint to be the final part of the column declaration and it was not obvious how to guarantee this (specifically, appending the CHECK constraint to the output of getJsonTypeDeclarationSQL() did not work). New public methods: MariaDBPlatform->getColumnTypeSQLSnippets() generates SQL snippets to reverse the JSON to LONGTEXT aliasing for JSON-specified columns. It is also used in MySQLSchemaManager. It still checks that json columns are JSON data type so that switching the getJsonTypeDeclarationSQL to LONGTEXT is all that is necessary to revert to old behaviour which is helpful for testing. Overridden methods in MariaDb1043Platform: MariaDb1043Platform->getJsonTypeDeclarationSQL(). To return JSON. MariaDBPlatform->getListTableColumnsSQL(). To reverse the JSON to LONGTEXT aliasing carried out by MariaDb. MariaDBPlatform->getColumnDeclarationSQL(). To unset collation and charset (used by the comparator). New test cases: 1. Types/JsonTest. Test storage and retrieval of json data. 2. Platforms/MariaDb1043PlatformTest. A clone of MariaDb1027Platform test. 3. Schema/MySQLSchemaManagerTest->testColumnIntrospection(). Ensures introspected table matches original table. Tests all doctrine types not just json. Based on failure highlighted in pull request doctrine#5100. For previous discussion on this topic, see: doctrine#5100 doctrine#3202 Further background at: https://mariadb.com/kb/en/json-data-type/ https://mariadb.com/kb/en/information-schema-check_constraints-table/ https://jira.mariadb.org/browse/MDEV-13916 Notes regarding JsonTest.php: 1. Some platforms return json as a stream so convert streams to strings. 2. 'json_table' is a reserved word in MySQL (and a function name in Oracle SQL). Use json_test_table instead. 3. Some platforms reorder json arrays so the insert order will not necessarily match the select order. Resort the arrays before testing for equality.
MariaDb aliases columns specified as JSON to LONGTEXT. Since version 10.4.3, MariaDb adds a CHECK constraint to JSON columns to ensure they contain valid JSON and sets the column collation to utf8mb4_bin. Simply setting JSON as the column type in the platform results in introspection failures as the database reports LONGTEXT (not JSON) with changed collation. Therefore, inverse the aliasing where the relevant check constraint exists and ignore collation changes for JSON columns in the relevant database versions. The main functional changes are in: - MariaDB1043Platform->getListTableColumnsSQL() and - MySQLSchemaManager->selectTableColumns() MariaDb1043Platform extends MariaDb1027Platform rather than MariaDBPlatform to ensure the platform checks in MySQLSchemaManager (based on MariaDb1027Platform) continue to work as expected. The alternative approach of adding the CHECK constraint to the SQL for the column is not robust as MariaDb syntax seems to require the CHECK constraint to be the final part of the column declaration and it was not obvious how to guarantee this (specifically, appending the CHECK constraint to the output of getJsonTypeDeclarationSQL() did not work). New public methods: MariaDBPlatform->getColumnTypeSQLSnippets() generates SQL snippets to reverse the JSON to LONGTEXT aliasing for JSON-specified columns. It is also used in MySQLSchemaManager. It still checks that json columns are JSON data type so that switching the getJsonTypeDeclarationSQL to LONGTEXT is all that is necessary to revert to old behaviour which is helpful for testing. Overridden methods in MariaDb1043Platform: MariaDb1043Platform->getJsonTypeDeclarationSQL(). To return JSON. MariaDBPlatform->getListTableColumnsSQL(). To reverse the JSON to LONGTEXT aliasing carried out by MariaDb. MariaDBPlatform->getColumnDeclarationSQL(). To unset collation and charset (used by the comparator). New test cases: 1. Types/JsonTest. Test storage and retrieval of json data. 2. Platforms/MariaDb1043PlatformTest. A clone of MariaDb1027Platform test. 3. Schema/MySQLSchemaManagerTest->testColumnIntrospection(). Ensures introspected table matches original table. Tests all doctrine types not just json. Based on failure highlighted in pull request doctrine#5100. For previous discussion on this topic, see: doctrine#5100 doctrine#3202 Further background at: https://mariadb.com/kb/en/json-data-type/ https://mariadb.com/kb/en/information-schema-check_constraints-table/ https://jira.mariadb.org/browse/MDEV-13916 Notes regarding JsonTest.php: 1. Some platforms return json as a stream so convert streams to strings. 2. 'json_table' is a reserved word in MySQL (and a function name in Oracle SQL). Use json_test_table instead. 3. Some platforms reorder json arrays so the insert order will not necessarily match the select order. Resort the arrays before testing for equality.
Feature Request
Summary
52b4692 disabled JSON support for MariaDB 10.2, since the engine is based on 5.6.
MariaDB 10.3 doesn't have its own platform file, but I think it needs one now to enable native JSON storage.
WDYT?
The text was updated successfully, but these errors were encountered: