MCPcopy
hub / github.com/sqldef/sqldef / FilterTables

Function FilterTables

schema/generator.go:6055–6083  ·  view source on GitHub ↗
(ddls []DDL, config database.GeneratorConfig)

Source from the content-addressed store, hash-verified

6053}
6054
6055func 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
6085func skipTables(tables []string, config database.GeneratorConfig) bool {
6086 if config.TargetTables != nil {

Callers 2

RunFunction · 0.92
GenerateIdempotentDDLsFunction · 0.85

Calls 2

skipTablesFunction · 0.85
RawStringMethod · 0.80

Tested by

no test coverage detected