Skip to content

Commit

Permalink
Merge pull request #68 from sev-2/hotfix/import
Browse files Browse the repository at this point in the history
Fix import from loaded state
  • Loading branch information
toopay authored Sep 13, 2024
2 parents 12560fc + 1acb72f commit 35dc3c6
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions pkg/resource/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func filterFunctionBySchema(input []objects.Function, allowedSchema ...string) (
t := input[i]

if _, exist := mapSchema[t.Schema]; exist {
ImportLogger.Debug("spFunction", "append", t)
output = append(output, t)
}
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/resource/rpc/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,13 @@ func CompareList(sourceFn []objects.Function, targetFn []objects.Function) (diff
for i := range targetFn {
f := targetFn[i]
mapTargetFn[f.Name] = f
Logger.Debug("TargetFn", "target-name", f)
}

for i := range sourceFn {
s := sourceFn[i]
s.CompleteStatement = strings.ReplaceAll(s.CompleteStatement, "search_path TO", "search_path =")
Logger.Debug("SourceFn", "source-name", s)

t, isExist := mapTargetFn[s.Name]
if !isExist {
Expand Down
5 changes: 4 additions & 1 deletion pkg/resource/tables/compare.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ func CompareItem(source, target objects.Table) (diffResult CompareDiffResult) {
if len(updateItem.ChangeItems) == 0 && len(updateItem.ChangeColumnItems) == 0 && len(updateItem.ChangeRelationItems) == 0 {
diffResult.IsConflict = false
} else {
Logger.Debug("changeItems", "conflict-check", updateItem.ChangeItems)
Logger.Debug("changeColumnItems", "conflict-check", updateItem.ChangeColumnItems)
Logger.Debug("changeRelationItems", "conflict-check", updateItem.ChangeRelationItems)
diffResult.IsConflict = true
}

Expand Down Expand Up @@ -222,7 +225,7 @@ func compareRelations(table *objects.Table, source, target []objects.TablesRelat
}

if !strings.HasPrefix(sc.ConstraintName, fmt.Sprintf("%s_", sc.SourceSchema)) {
Logger.Info("constrain name update", "from", sc.ConstraintName, "to", fmt.Sprintf("%s_%s", sc.SourceSchema, sc.ConstraintName))
Logger.Debug("constrain name update", "from", sc.ConstraintName, "to", fmt.Sprintf("%s_%s", sc.SourceSchema, sc.ConstraintName))
sc.ConstraintName = fmt.Sprintf("%s_%s", sc.SourceSchema, sc.ConstraintName)
}

Expand Down
2 changes: 1 addition & 1 deletion rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ func (r *RpcBase) SetCompleteStmt(stmt string) {
}

func (r *RpcBase) GetCompleteStmt() string {
return r.CompleteStatement
return strings.ReplaceAll(r.CompleteStatement, "search_path to ", "search_path = ")
}

// ----- Rpc Param Functionality -----
Expand Down

0 comments on commit 35dc3c6

Please sign in to comment.