File tree Expand file tree Collapse file tree 4 files changed +12
-37
lines changed
adminforth/dataConnectors Expand file tree Collapse file tree 4 files changed +12
-37
lines changed Original file line number Diff line number Diff line change @@ -507,6 +507,17 @@ export default class AdminForthBaseConnector implements IAdminForthDataSourceCon
507507 return result ;
508508 }
509509
510+ async checkCascadeWhenUploadPlugin ( resource : AdminForthResource , config : AdminForthConfig ) {
511+ const currentResource = config . resources . find ( r => r . resourceId === resource . resourceId ) ;
512+ if ( ! currentResource ) return ;
513+ const hasUploadPlugin = currentResource . plugins ?. some ( p => p . className === "UploadPlugin" ) ;
514+
515+ if ( hasUploadPlugin ) {
516+ const tableName = ( resource . table ) ;
517+ afLogger . warn ( `Table "${ tableName } " has ON DELETE CASCADE, which may conflict with adminForth UploadPlugin.` ) ;
518+ }
519+ }
520+
510521 getRecordByPrimaryKey ( resource : AdminForthResource , recordId : string ) : Promise < any > {
511522 return this . getRecordByPrimaryKeyWithOriginalTypes ( resource , recordId ) . then ( ( record ) => {
512523 const newRecord = { } ;
Original file line number Diff line number Diff line change @@ -74,17 +74,6 @@ class MysqlConnector extends AdminForthBaseConnector implements IAdminForthDataS
7474 } ) ) ;
7575 }
7676
77- async checkCascadeWhenUploadPlugin ( resource : AdminForthResource , config : AdminForthConfig ) {
78- const currentResource = config . resources . find ( r => r . resourceId === resource . resourceId ) ;
79- if ( ! currentResource ) return ;
80- const hasUploadPlugin = currentResource . plugins ?. some ( p => p . className === "UploadPlugin" ) ;
81-
82- if ( hasUploadPlugin ) {
83- const tableName = ( resource . table ) ;
84- afLogger . warn ( `Table "${ tableName } " has ON DELETE CASCADE, which may conflict with adminForth UploadPlugin.` ) ;
85- }
86- }
87-
8877 async hasMySQLCascadeFk ( resource : AdminForthResource , config : AdminForthConfig ) : Promise < boolean > {
8978
9079 const cascadeColumn = resource . columns . find ( c => c . foreignResource ?. onDelete === 'cascade' ) ;
Original file line number Diff line number Diff line change @@ -96,19 +96,6 @@ class PostgresConnector extends AdminForthBaseConnector implements IAdminForthDa
9696 return hasCascade ;
9797 }
9898
99- async checkCascadeWhenUploadPlugin ( resource : AdminForthResource , config : AdminForthConfig ) {
100- const currentResource = config . resources . find ( r => r . resourceId === resource . resourceId ) ;
101- if ( ! currentResource ) return ;
102- const hasUploadPlugin = currentResource . plugins ?. some ( p => p . className === "UploadPlugin" ) ;
103-
104- if ( hasUploadPlugin ) {
105- const tableName = ( resource . table ) ;
106- afLogger . warn (
107- `Table "${ tableName } " has ON DELETE CASCADE, which may conflict with adminForth UploadPlugin.`
108- ) ;
109- }
110- }
111-
11299 async discoverFields ( resource : AdminForthResource , config : AdminForthConfig ) {
113100 await this . checkForeignResourceCascade ( resource , config ) ;
114101 await this . checkCascadeWhenUploadPlugin ( resource , config ) ;
Original file line number Diff line number Diff line change @@ -37,25 +37,13 @@ class SQLiteConnector extends AdminForthBaseConnector implements IAdminForthData
3737 sampleValue : sampleRow [ col . name ] ,
3838 } ) ) ;
3939 }
40-
41- async checkCascadeWhenUploadPlugin ( resource : AdminForthResource , config : AdminForthConfig ) {
42- const currentResource = config . resources . find ( r => r . resourceId === resource . resourceId ) ;
43- if ( ! currentResource ) return ;
44- const hasUploadPlugin = currentResource . plugins ?. some ( p => p . className === "UploadPlugin" ) ;
45-
46- if ( hasUploadPlugin ) {
47- const tableName = ( resource . table ) ;
48- afLogger . warn ( `Table "${ tableName } " has ON DELETE CASCADE, which may conflict with adminForth UploadPlugin.` ) ;
49- }
50- }
51-
40+
5241 async hasSQLiteCascadeFk ( resource : AdminForthResource , config : AdminForthConfig , fkMap : { [ colName : string ] : boolean } ) : Promise < boolean > {
5342
5443 const hasAdminCascade = resource . columns ?. some ( c => c . foreignResource ?. onDelete === 'cascade' ) ;
5544 if ( ! hasAdminCascade ) return false ;
5645
5746 const hasDbCascade = Object . values ( fkMap ) . some ( v => v ) ;
58- console . log ( "resource.resourceId" , resource . resourceId ) ;
5947
6048 if ( hasDbCascade ) {
6149 const tableName = ( resource . table ) ;
You can’t perform that action at this time.
0 commit comments