2323
2424namespace Codappix \Typo3PhpDatasets ;
2525
26+ use Doctrine \DBAL \Schema \Exception \ColumnDoesNotExist ;
2627use RuntimeException ;
2728use TYPO3 \CMS \Core \Database \ConnectionPool ;
2829use TYPO3 \CMS \Core \Utility \GeneralUtility ;
@@ -39,15 +40,33 @@ public function import(array $dataSet): void
3940 $ tableDetails = $ connection ->getSchemaManager ()->listTableDetails ($ tableName );
4041 } elseif (method_exists ($ connection , 'getSchemaInformation ' )) {
4142 // >= 13
42- $ tableDetails = $ connection ->getSchemaInformation ()->introspectTable ($ tableName );
43+ $ tableDetails = $ connection ->getSchemaInformation ()->getTableInfo ($ tableName );
4344 } else {
4445 throw new RuntimeException ('Could not check the schema for table: ' . $ tableName , 1707144020 );
4546 }
4647
4748 foreach ($ records as $ record ) {
4849 $ types = [];
4950 foreach (array_keys ($ record ) as $ columnName ) {
50- $ types [] = $ tableDetails ->getColumn ((string )$ columnName )->getType ()->getBindingType ();
51+ if (method_exists ($ tableDetails , 'getColumn ' )) {
52+ // <= 12
53+ try {
54+ $ column = $ tableDetails ->getColumn ((string )$ columnName );
55+ } catch (ColumnDoesNotExist $ exception ) {
56+ throw new RuntimeException ('Column " ' . $ columnName . '" does not exist in table: ' . $ tableName , 1760699318 );
57+ }
58+ } else if (method_exists ($ tableDetails , 'getColumnInfo ' )) {
59+ // >= 13
60+ $ column = $ tableDetails ->getColumnInfo ((string )$ columnName );
61+
62+ if ($ column === null ) {
63+ throw new RuntimeException ('Column " ' . $ columnName . '" does not exist in table: ' . $ tableName , 1760699318 );
64+ }
65+ } else {
66+ throw new RuntimeException ('Could not get info for column " ' . $ columnName . '" of table: ' . $ tableName , 1760697878 );
67+ }
68+
69+ $ types [] = $ column ->getType ()->getBindingType ();
5170 }
5271
5372 $ connection ->insert ($ tableName , $ record , $ types );
0 commit comments