|
|
@ -83,8 +83,9 @@ func Parse(filename, database string, strict bool) ([]*Table, error) {
|
|
|
|
primaryColumn string
|
|
|
|
primaryColumn string
|
|
|
|
primaryColumnSet = collection.NewSet()
|
|
|
|
primaryColumnSet = collection.NewSet()
|
|
|
|
uniqueKeyMap = make(map[string][]string)
|
|
|
|
uniqueKeyMap = make(map[string][]string)
|
|
|
|
normalKeyMap = make(map[string][]string)
|
|
|
|
// Unused local variable
|
|
|
|
columns = e.Columns
|
|
|
|
// normalKeyMap = make(map[string][]string)
|
|
|
|
|
|
|
|
columns = e.Columns
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
for _, column := range columns {
|
|
|
|
for _, column := range columns {
|
|
|
@ -144,20 +145,26 @@ func Parse(filename, database string, strict bool) ([]*Table, error) {
|
|
|
|
|
|
|
|
|
|
|
|
var (
|
|
|
|
var (
|
|
|
|
uniqueIndex = make(map[string][]*Field)
|
|
|
|
uniqueIndex = make(map[string][]*Field)
|
|
|
|
normalIndex = make(map[string][]*Field)
|
|
|
|
// Unused local variable
|
|
|
|
|
|
|
|
// normalIndex = make(map[string][]*Field)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
for indexName, each := range uniqueKeyMap {
|
|
|
|
for indexName, each := range uniqueKeyMap {
|
|
|
|
for _, columnName := range each {
|
|
|
|
for _, columnName := range each {
|
|
|
|
|
|
|
|
// Prevent a crash if there is a unique key constraint with a nil field.
|
|
|
|
|
|
|
|
if fieldM[columnName] == nil {
|
|
|
|
|
|
|
|
return nil, fmt.Errorf("table %s: unique key with error column name[%s]", e.Name, columnName)
|
|
|
|
|
|
|
|
}
|
|
|
|
uniqueIndex[indexName] = append(uniqueIndex[indexName], fieldM[columnName])
|
|
|
|
uniqueIndex[indexName] = append(uniqueIndex[indexName], fieldM[columnName])
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for indexName, each := range normalKeyMap {
|
|
|
|
// Unused local variable
|
|
|
|
for _, columnName := range each {
|
|
|
|
// for indexName, each := range normalKeyMap {
|
|
|
|
normalIndex[indexName] = append(normalIndex[indexName], fieldM[columnName])
|
|
|
|
// for _, columnName := range each {
|
|
|
|
}
|
|
|
|
// normalIndex[indexName] = append(normalIndex[indexName], fieldM[columnName])
|
|
|
|
}
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
checkDuplicateUniqueIndex(uniqueIndex, e.Name)
|
|
|
|
checkDuplicateUniqueIndex(uniqueIndex, e.Name)
|
|
|
|
|
|
|
|
|
|
|
|