File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
lib/internal/Magento/Framework/Setup/Declaration/Schema Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -67,8 +67,9 @@ public function __construct(
6767
6868 /**
6969 * @inheritdoc
70+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
7071 */
71- public function build (Schema $ schema )
72+ public function build (Schema $ schema, $ tablesWithJsonTypeField = [] )
7273 {
7374 foreach ($ this ->sharding ->getResources () as $ resource ) {
7475 foreach ($ this ->dbSchemaReader ->readTables ($ resource ) as $ tableName ) {
@@ -95,9 +96,16 @@ public function build(Schema $schema)
9596 'collation ' => $ tableOptions ['collation ' ]
9697 ]
9798 );
99+ $ isJsonType = false ;
100+ if (count ($ tablesWithJsonTypeField ) > 0 && isset ($ tablesWithJsonTypeField [$ tableName ])) {
101+ $ isJsonType = true ;
102+ }
98103
99104 // Process columns
100105 foreach ($ columnsData as $ columnData ) {
106+ if ($ isJsonType && $ tablesWithJsonTypeField [$ tableName ] == $ columnData ['name ' ]) {
107+ $ columnData ['type ' ] = 'json ' ;
108+ }
101109 $ columnData ['table ' ] = $ table ;
102110 $ column = $ this ->elementFactory ->create ($ columnData ['type ' ], $ columnData );
103111 $ columns [$ column ->getName ()] = $ column ;
Original file line number Diff line number Diff line change @@ -62,8 +62,17 @@ public function __construct(
6262 */
6363 public function getDbConfig ()
6464 {
65+ $ declarativeSchema = $ this ->getDeclarationConfig ();
66+ $ tablesWithJsonTypeField = [];
67+ foreach ($ declarativeSchema ->getTables () as $ table ) {
68+ foreach ($ table ->getColumns () as $ column ) {
69+ if ($ column ->getType () == 'json ' ) {
70+ $ tablesWithJsonTypeField [$ table ->getName ()] = $ column ->getName ();
71+ }
72+ }
73+ }
6574 $ schema = $ this ->schemaFactory ->create ();
66- $ schema = $ this ->dbSchemaBuilder ->build ($ schema );
75+ $ schema = $ this ->dbSchemaBuilder ->build ($ schema, $ tablesWithJsonTypeField );
6776 return $ schema ;
6877 }
6978
You can’t perform that action at this time.
0 commit comments