(ddls []DDL, config database.GeneratorConfig)
| 6053 | } |
| 6054 | |
| 6055 | func FilterTables(ddls []DDL, config database.GeneratorConfig) []DDL { |
| 6056 | filtered := []DDL{} |
| 6057 | |
| 6058 | for _, ddl := range ddls { |
| 6059 | tables := []string{} |
| 6060 | |
| 6061 | switch stmt := ddl.(type) { |
| 6062 | case *CreateTable: |
| 6063 | tables = append(tables, stmt.table.name.RawString()) |
| 6064 | case *CreateIndex: |
| 6065 | tables = append(tables, stmt.tableName.RawString()) |
| 6066 | case *AddPrimaryKey: |
| 6067 | tables = append(tables, stmt.tableName.RawString()) |
| 6068 | case *AddForeignKey: |
| 6069 | tables = append(tables, stmt.tableName.RawString()) |
| 6070 | tables = append(tables, stmt.foreignKey.referenceTableName.RawString()) |
| 6071 | case *AddIndex: |
| 6072 | tables = append(tables, stmt.tableName.RawString()) |
| 6073 | } |
| 6074 | |
| 6075 | if skipTables(tables, config) { |
| 6076 | continue |
| 6077 | } |
| 6078 | |
| 6079 | filtered = append(filtered, ddl) |
| 6080 | } |
| 6081 | |
| 6082 | return filtered |
| 6083 | } |
| 6084 | |
| 6085 | func skipTables(tables []string, config database.GeneratorConfig) bool { |
| 6086 | if config.TargetTables != nil { |
no test coverage detected