MCPcopy Create free account
hub / github.com/bytebase/bytebase / findDisjointUniqueKey

Method findDisjointUniqueKey

backend/plugin/parser/plsql/restore.go:211–236  ·  view source on GitHub ↗
(columns []string)

Source from the content-addressed store, hash-verified

209}
210
211func (g *generator) findDisjointUniqueKey(columns []string) ([]string, error) {
212 columnMap := make(map[string]bool)
213 for _, column := range columns {
214 columnMap[column] = true
215 }
216 if g.pk != nil {
217 if disjoint(g.pk.GetProto().Expressions, columnMap) {
218 return g.pk.GetProto().Expressions, nil
219 }
220 }
221 for _, index := range g.table.GetProto().Indexes {
222 if index.Primary {
223 continue
224 }
225 if !index.Unique {
226 continue
227 }
228 if strings.Contains(index.Type, "FUNCTION-BASED") {
229 continue
230 }
231 if disjoint(index.Expressions, columnMap) {
232 return index.Expressions, nil
233 }
234 }
235 return nil, errors.Errorf("no disjoint unique key found for %s.%s", g.originalDatabase, g.originalTable)
236}
237
238func (g *generator) generateUpdate(stmt *oracleast.UpdateStmt) error {
239 updateColumns := extractOmniUpdateColumns(stmt)

Callers 1

generateUpdateMethod · 0.95

Calls 3

ErrorfMethod · 0.80
disjointFunction · 0.70
GetProtoMethod · 0.45

Tested by

no test coverage detected