-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Add support for char element to dto factory #22442
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
Add support for char element to dto factory #22442
Conversation
To avoid the notice "Types char is not declared" (which breaks setup:upgrade) when using the very type anywhere in the MySQL database, mapping for this specific type is added to the DI as well.
Hi @wardcapp. Thank you for your contribution
For more details, please, review the Magento Contributor Assistant documentation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this is slightly related to #1392. Why do we need to add CHAR
mapping if it's not used in Magento?
This PR does slightly relate to #1392, which indeed explains why most of the users aren't applying the
Could be wrong still / assumptions made could be incorrect, so please feel free to provide feedback. |
Thanks @wardcapp! @skovalenk @rganin @akaplya is there any reason to disallow |
I am encountering the issue This pull request could solve my issue. |
@@ -1435,6 +1435,7 @@ | |||
<item name="mediumtext" xsi:type="object">\Magento\Framework\Setup\Declaration\Schema\Dto\Factories\MediumText</item> | |||
<item name="text" xsi:type="object">\Magento\Framework\Setup\Declaration\Schema\Dto\Factories\Text</item> | |||
<item name="varchar" xsi:type="object">\Magento\Framework\Setup\Declaration\Schema\Dto\Factories\StringBinary</item> | |||
<item name="char" xsi:type="object">\Magento\Framework\Setup\Declaration\Schema\Dto\Factories\StringBinary</item> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not enough to add char in di.xml, you need to fix db_scrma definition too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First of all, thank you for the follow-up! Not quite sure if I am understanding this correctly - did you mean the DB schema type declarations (within the very same di.xml)? If so, char has already been defined there as well within the current 2.3-develop branch (see app/etc/di.xml:1471).
Apart from that, it is possible to add support for the char type to Magento 2 setup scripts. Which would require adding of a char schema setup declaration (similar to lib/internal/Magento/Framework/Setup/Declaration/Schema/etc/schema.xsd:22) indeed, but does not relate to the intent of this pull request (and could be set up over a separate PR or feature request). But I might still be overlooking another required type of definition?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sidolov please respond :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @wardcapp This is a good idea extending compatible types, but unfortunately, this is not as easy as change one XSD. Here is an example of adding a new data type to a declarative schema. https://github.com/magento/magento2/pull/25479/files
In your case, it even could be more complicated because the CHAR type supports more options that JSON. Also, you can take a look at VARCHAR implementation as an example.
i will provide support for db_schema |
@wardcapp could you please sign CLA so our team will be able to finish this PR? |
Hi @lenaorobei, CLA has been signed and related check should pass now. |
7c5471c
to
8741cd0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Nazar65 looks good to me except the small typo 👍
Please fix it and squash your changes into a single commit.
<xs:extension base="abstractColumnType"> | ||
<xs:annotation> | ||
<xs:documentation> | ||
Here plain text can be persisted without trailing spaces. Length of this field cant be more than 255 characters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: "cannot" or "can't"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, thank you 👍
c23a0a5
to
58dde94
Compare
@orlangur thank you for your review, done ✔️ |
✔️ QA Passed |
@magento run all tests |
1 similar comment
@magento run all tests |
Hi @lenaorobei, thank you for the review. |
Hi @wardcapp, thank you for your contribution! |
To avoid the notice "Types char is not declared" (which breaks setup:upgrade) when using the very type anywhere in the MySQL database, mapping for this specific type is added to the DI as well.
Description
Adds the CHAR MySQL column type to the schema type declaration factory (di.xml). Which becomes required as soon as CHAR type has been used anywhere within the connected database - applies to non-Magento tables as well, since they are validated / scanned too upon executing setup:upgrade.
Fixed Issues
https://community.magento.com/t5/Magento-2-x-Version-Upgrades/Upgrade-Issue-2-2-7-to-2-3-0-Types-char-is-not-declared/td-p/114939
Manual testing scenarios
db_schema.xml
Structure of created table
Contribution checklist