mirror of https://github.com/go-gorm/gorm.git
more tracing
This commit is contained in:
parent
38fb45fea8
commit
3198b7c219
|
@ -710,6 +710,7 @@ func (m Migrator) GuessConstraintInterfaceAndTable(stmt *gorm.Statement, name st
|
||||||
|
|
||||||
for _, rel := range stmt.Schema.Relationships.Relations {
|
for _, rel := range stmt.Schema.Relationships.Relations {
|
||||||
if constraint := rel.ParseConstraint(); constraint != nil && constraint.Name == name {
|
if constraint := rel.ParseConstraint(); constraint != nil && constraint.Name == name {
|
||||||
|
fmt.Println(fmt.Sprintf("SHREWS --Out of Guess for relation 0 %q", constraint))
|
||||||
return constraint, getTable(rel)
|
return constraint, getTable(rel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -718,6 +719,7 @@ func (m Migrator) GuessConstraintInterfaceAndTable(stmt *gorm.Statement, name st
|
||||||
for k := range checkConstraints {
|
for k := range checkConstraints {
|
||||||
if checkConstraints[k].Field == field {
|
if checkConstraints[k].Field == field {
|
||||||
v := checkConstraints[k]
|
v := checkConstraints[k]
|
||||||
|
fmt.Println(fmt.Sprintf("SHREWS --Out of Guess for check %q", &v))
|
||||||
return &v, stmt.Table
|
return &v, stmt.Table
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -725,12 +727,14 @@ func (m Migrator) GuessConstraintInterfaceAndTable(stmt *gorm.Statement, name st
|
||||||
for k := range uniqueConstraints {
|
for k := range uniqueConstraints {
|
||||||
if uniqueConstraints[k].Field == field {
|
if uniqueConstraints[k].Field == field {
|
||||||
v := uniqueConstraints[k]
|
v := uniqueConstraints[k]
|
||||||
|
fmt.Println(fmt.Sprintf("SHREWS --Out of Guess for unique %q", &v))
|
||||||
return &v, stmt.Table
|
return &v, stmt.Table
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, rel := range stmt.Schema.Relationships.Relations {
|
for _, rel := range stmt.Schema.Relationships.Relations {
|
||||||
if constraint := rel.ParseConstraint(); constraint != nil && rel.Field == field {
|
if constraint := rel.ParseConstraint(); constraint != nil && rel.Field == field {
|
||||||
|
fmt.Println(fmt.Sprintf("SHREWS --Out of Guess for relation %q", constraint))
|
||||||
return constraint, getTable(rel)
|
return constraint, getTable(rel)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -757,10 +761,10 @@ func (m Migrator) CreateConstraint(value interface{}, name string) error {
|
||||||
|
|
||||||
// DropConstraint drop constraint
|
// DropConstraint drop constraint
|
||||||
func (m Migrator) DropConstraint(value interface{}, name string) error {
|
func (m Migrator) DropConstraint(value interface{}, name string) error {
|
||||||
|
fmt.Println(fmt.Sprintf("SHREWS --In Drop %q", name))
|
||||||
return m.RunWithValue(value, func(stmt *gorm.Statement) error {
|
return m.RunWithValue(value, func(stmt *gorm.Statement) error {
|
||||||
if !m.HasConstraint(value, name) {
|
if !m.HasConstraint(value, name) {
|
||||||
constraint, _ := m.GuessConstraintInterfaceAndTable(stmt, name)
|
return nil
|
||||||
return errors.New(fmt.Sprintf("Can't find constraint for %q, with guessed name %q", name, constraint))
|
|
||||||
}
|
}
|
||||||
constraint, table := m.GuessConstraintInterfaceAndTable(stmt, name)
|
constraint, table := m.GuessConstraintInterfaceAndTable(stmt, name)
|
||||||
if constraint != nil {
|
if constraint != nil {
|
||||||
|
|
Loading…
Reference in New Issue