@@ -1734,21 +1734,26 @@ protected function getRelationShipColumns($select) {
1734
1734
return $ keep ;
1735
1735
}
1736
1736
1737
- protected function findFields ($ tables ,$ columns , $ exclude , $ select , $ database ) {
1737
+ protected function findFields ($ tables ,$ database ) {
1738
1738
$ fields = array ();
1739
+ foreach ($ tables as $ i =>$ table ) {
1740
+ $ fields [$ table ] = $ this ->findTableFields ($ table ,$ database );
1741
+ }
1742
+ return $ fields ;
1743
+ }
1744
+
1745
+ protected function limitFields ($ fields ,$ columns ,$ exclude ,$ select ) {
1739
1746
if ($ select && ($ columns || $ exclude )) {
1740
1747
$ keep = $ this ->getRelationShipColumns ($ select );
1741
1748
} else {
1742
1749
$ keep = false ;
1743
1750
}
1744
- foreach ($ tables as $ i =>$ table ) {
1745
- $ fields [$ table ] = $ this ->findTableFields ($ table ,$ database );
1751
+ foreach (array_keys ($ fields ) as $ i =>$ table ) {
1746
1752
$ fields [$ table ] = $ this ->filterFieldsByColumns ($ fields [$ table ],$ columns ,$ keep ,$ i ==0 ,$ table );
1747
1753
$ fields [$ table ] = $ this ->filterFieldsByExclude ($ fields [$ table ],$ exclude ,$ keep ,$ i ==0 ,$ table );
1748
1754
}
1749
1755
return $ fields ;
1750
1756
}
1751
-
1752
1757
protected function filterFieldsByColumns ($ fields ,$ columns ,$ keep ,$ first ,$ table ) {
1753
1758
if ($ columns ) {
1754
1759
$ columns = explode (', ' ,$ columns );
@@ -1902,13 +1907,14 @@ protected function getParameters($settings) {
1902
1907
1903
1908
// reflection
1904
1909
list ($ tables ,$ collect ,$ select ) = $ this ->findRelations ($ tables ,$ database ,$ auto_include );
1905
- $ fields = $ this ->findFields ($ tables ,$ columns ,$ exclude ,$ select ,$ database );
1906
-
1910
+ $ fields = $ this ->findFields ($ tables ,$ database );
1911
+ if ($ tenancy_function ) $ this ->applyTenancyFunction ($ tenancy_function ,$ action ,$ database ,$ fields ,$ filters );
1912
+ $ fields = $ this ->limitFields ($ fields ,$ columns ,$ exclude ,$ select ,$ database );
1913
+
1907
1914
// permissions
1908
1915
if ($ table_authorizer ) $ this ->applyTableAuthorizer ($ table_authorizer ,$ action ,$ database ,$ tables );
1909
1916
if (!isset ($ tables [0 ])) $ this ->exitWith404 ('entity ' );
1910
1917
if ($ record_filter ) $ this ->applyRecordFilter ($ record_filter ,$ action ,$ database ,$ tables ,$ filters );
1911
- if ($ tenancy_function ) $ this ->applyTenancyFunction ($ tenancy_function ,$ action ,$ database ,$ fields ,$ filters );
1912
1918
if ($ column_authorizer ) $ this ->applyColumnAuthorizer ($ column_authorizer ,$ action ,$ database ,$ fields );
1913
1919
1914
1920
// input
@@ -2285,7 +2291,7 @@ protected function swagger($settings) {
2285
2291
$ table_names = array_map (function ($ v ){ return $ v ['name ' ];},$ tables );
2286
2292
foreach ($ tables as $ t =>$ table ) {
2287
2293
$ table_list = array ($ table ['name ' ]);
2288
- $ table_fields = $ this ->findFields ($ table_list ,false , false , false , $ database );
2294
+ $ table_fields = $ this ->findFields ($ table_list ,$ database );
2289
2295
2290
2296
// extensions
2291
2297
$ result = $ this ->db ->query ($ this ->db ->getSql ('reflect_belongs_to ' ),array ($ table_list [0 ],$ table_names ,$ database ,$ database ));
0 commit comments