@@ -667,7 +667,7 @@ public function __construct(GenericDB $db, ReflectionService $reflection)
667667
668668 public function updateTable (String $ tableName , /* object */ $ changes ): bool
669669 {
670- $ table = $ this -> reflection -> getTable ($ tableName );
670+ $ table = $ database -> get ($ tableName );
671671 $ newTable = ReflectedTable::fromJson ((object ) array_merge ((array ) $ table ->jsonSerialize (), (array ) $ changes ));
672672 if ($ table ->getName () != $ newTable ->getName ()) {
673673 if (!$ this ->db ->definition ()->renameTable ($ table ->getName (), $ newTable ->getName ())) {
@@ -679,7 +679,7 @@ public function updateTable(String $tableName, /* object */ $changes): bool
679679
680680 public function updateColumn (String $ tableName , String $ columnName , /* object */ $ changes ): bool
681681 {
682- $ table = $ this -> reflection -> getTable ($ tableName );
682+ $ table = $ database -> get ($ tableName );
683683 $ column = $ table ->get ($ columnName );
684684
685685 $ newColumn = ReflectedColumn::fromJson ((object ) array_merge ((array ) $ column ->jsonSerialize (), (array ) $ changes ));
@@ -780,7 +780,7 @@ public function removeTable(String $tableName)
780780
781781 public function removeColumn (String $ tableName , String $ columnName )
782782 {
783- $ table = $ this -> reflection -> getTable ($ tableName );
783+ $ table = $ database -> get ($ tableName );
784784 $ newColumn = $ table ->get ($ columnName );
785785 if ($ newColumn ->getPk ()) {
786786 $ newColumn ->setPk (false );
@@ -901,21 +901,23 @@ public function getDatabase(Request $request): Response
901901 public function getTable (Request $ request ): Response
902902 {
903903 $ tableName = $ request ->getPathSegment (2 );
904- if (!$ this ->reflection ->hasTable ($ tableName )) {
904+ $ database = $ this ->reflection ->getDatabase ();
905+ if (!$ database ->exists ($ tableName )) {
905906 return $ this ->responder ->error (ErrorCode::TABLE_NOT_FOUND , $ tableName );
906907 }
907- $ table = $ this -> reflection -> getTable ($ tableName );
908+ $ table = $ database -> get ($ tableName );
908909 return $ this ->responder ->success ($ table );
909910 }
910911
911912 public function getColumn (Request $ request ): Response
912913 {
913914 $ tableName = $ request ->getPathSegment (2 );
914915 $ columnName = $ request ->getPathSegment (3 );
915- if (!$ this ->reflection ->hasTable ($ tableName )) {
916+ $ database = $ this ->reflection ->getDatabase ();
917+ if (!$ database ->exists ($ tableName )) {
916918 return $ this ->responder ->error (ErrorCode::TABLE_NOT_FOUND , $ tableName );
917919 }
918- $ table = $ this -> reflection -> getTable ($ tableName );
920+ $ table = $ database -> get ($ tableName );
919921 if (!$ table ->exists ($ columnName )) {
920922 return $ this ->responder ->error (ErrorCode::COLUMN_NOT_FOUND , $ columnName );
921923 }
@@ -926,7 +928,8 @@ public function getColumn(Request $request): Response
926928 public function updateTable (Request $ request ): Response
927929 {
928930 $ tableName = $ request ->getPathSegment (2 );
929- if (!$ this ->reflection ->hasTable ($ tableName )) {
931+ $ database = $ this ->reflection ->getDatabase ();
932+ if (!$ database ->exists ($ tableName )) {
930933 return $ this ->responder ->error (ErrorCode::TABLE_NOT_FOUND , $ tableName );
931934 }
932935 $ success = $ this ->definition ->updateTable ($ tableName , $ request ->getBody ());
@@ -940,10 +943,11 @@ public function updateColumn(Request $request): Response
940943 {
941944 $ tableName = $ request ->getPathSegment (2 );
942945 $ columnName = $ request ->getPathSegment (3 );
943- if (!$ this ->reflection ->hasTable ($ tableName )) {
946+ $ database = $ this ->reflection ->getDatabase ();
947+ if (!$ database ->exists ($ tableName )) {
944948 return $ this ->responder ->error (ErrorCode::TABLE_NOT_FOUND , $ tableName );
945949 }
946- $ table = $ this -> reflection -> getTable ($ tableName );
950+ $ table = $ database -> get ($ tableName );
947951 if (!$ table ->exists ($ columnName )) {
948952 return $ this ->responder ->error (ErrorCode::COLUMN_NOT_FOUND , $ columnName );
949953 }
@@ -970,11 +974,12 @@ public function addTable(Request $request): Response
970974 public function addColumn (Request $ request ): Response
971975 {
972976 $ tableName = $ request ->getPathSegment (2 );
973- if (!$ this ->reflection ->hasTable ($ tableName )) {
977+ $ database = $ this ->reflection ->getDatabase ();
978+ if (!$ database ->exists ($ tableName )) {
974979 return $ this ->responder ->error (ErrorCode::TABLE_NOT_FOUND , $ tableName );
975980 }
976981 $ columnName = $ request ->getBody ()->name ;
977- $ table = $ this -> reflection -> getTable ($ tableName );
982+ $ table = $ database -> get ($ tableName );
978983 if ($ table ->exists ($ columnName )) {
979984 return $ this ->responder ->error (ErrorCode::COLUMN_ALREADY_EXISTS , $ columnName );
980985 }
@@ -988,7 +993,8 @@ public function addColumn(Request $request): Response
988993 public function removeTable (Request $ request ): Response
989994 {
990995 $ tableName = $ request ->getPathSegment (2 );
991- if (!$ this ->reflection ->hasTable ($ tableName )) {
996+ $ database = $ this ->reflection ->getDatabase ();
997+ if (!$ database ->exists ($ tableName )) {
992998 return $ this ->responder ->error (ErrorCode::TABLE_NOT_FOUND , $ tableName );
993999 }
9941000 $ success = $ this ->definition ->removeTable ($ tableName );
@@ -1002,10 +1008,11 @@ public function removeColumn(Request $request): Response
10021008 {
10031009 $ tableName = $ request ->getPathSegment (2 );
10041010 $ columnName = $ request ->getPathSegment (3 );
1005- if (!$ this ->reflection ->hasTable ($ tableName )) {
1011+ $ database = $ this ->reflection ->getDatabase ();
1012+ if (!$ database ->exists ($ tableName )) {
10061013 return $ this ->responder ->error (ErrorCode::TABLE_NOT_FOUND , $ tableName );
10071014 }
1008- $ table = $ this -> reflection -> getTable ($ tableName );
1015+ $ table = $ database -> get ($ tableName );
10091016 if (!$ table ->exists ($ columnName )) {
10101017 return $ this ->responder ->error (ErrorCode::COLUMN_NOT_FOUND , $ columnName );
10111018 }
0 commit comments