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(
67
67
68
68
/**
69
69
* @inheritdoc
70
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
70
71
*/
71
- public function build (Schema $ schema )
72
+ public function build (Schema $ schema, $ tablesWithJsonTypeField = [] )
72
73
{
73
74
foreach ($ this ->sharding ->getResources () as $ resource ) {
74
75
foreach ($ this ->dbSchemaReader ->readTables ($ resource ) as $ tableName ) {
@@ -95,9 +96,16 @@ public function build(Schema $schema)
95
96
'collation ' => $ tableOptions ['collation ' ]
96
97
]
97
98
);
99
+ $ isJsonType = false ;
100
+ if (count ($ tablesWithJsonTypeField ) > 0 && isset ($ tablesWithJsonTypeField [$ tableName ])) {
101
+ $ isJsonType = true ;
102
+ }
98
103
99
104
// Process columns
100
105
foreach ($ columnsData as $ columnData ) {
106
+ if ($ isJsonType && $ tablesWithJsonTypeField [$ tableName ] == $ columnData ['name ' ]) {
107
+ $ columnData ['type ' ] = 'json ' ;
108
+ }
101
109
$ columnData ['table ' ] = $ table ;
102
110
$ column = $ this ->elementFactory ->create ($ columnData ['type ' ], $ columnData );
103
111
$ columns [$ column ->getName ()] = $ column ;
Original file line number Diff line number Diff line change @@ -62,8 +62,17 @@ public function __construct(
62
62
*/
63
63
public function getDbConfig ()
64
64
{
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
+ }
65
74
$ schema = $ this ->schemaFactory ->create ();
66
- $ schema = $ this ->dbSchemaBuilder ->build ($ schema );
75
+ $ schema = $ this ->dbSchemaBuilder ->build ($ schema, $ tablesWithJsonTypeField );
67
76
return $ schema ;
68
77
}
69
78
You can’t perform that action at this time.
0 commit comments