entc/internal: add snapshot restore logic (#862)

Issue #852
This commit is contained in:
Ariel Mashraki
2020-10-19 14:51:28 +03:00
committed by GitHub
parent d6fd283f68
commit 98aeb19013
15 changed files with 460 additions and 23 deletions

View File

@@ -1924,7 +1924,7 @@ func (b *Builder) Quote(ident string) string {
// If it was quoted with the wrong
// identifier character.
if strings.Contains(ident, "`") {
return strings.Replace(ident, "`", `"`, -1)
return strings.ReplaceAll(ident, "`", `"`)
}
return strconv.Quote(ident)
// An identifier for unknown dialect.
@@ -1944,7 +1944,7 @@ func (b *Builder) Ident(s string) *Builder {
case (isFunc(s) || isModifier(s)) && b.postgres():
// Modifiers and aggregation functions that
// were called without dialect information.
b.WriteString(strings.Replace(s, "`", `"`, -1))
b.WriteString(strings.ReplaceAll(s, "`", `"`))
default:
b.WriteString(s)
}

View File

@@ -249,7 +249,7 @@ func (c *Column) defaultValue(b *sql.ColumnBuilder) {
attr += strconv.FormatBool(v)
case string:
// Escape single quote by replacing each with 2.
attr += fmt.Sprintf("'%s'", strings.Replace(v, "'", "''", -1))
attr += fmt.Sprintf("'%s'", strings.ReplaceAll(v, "'", "''"))
default:
attr += fmt.Sprint(v)
}
@@ -361,7 +361,7 @@ func (r ReferenceOption) ConstName() string {
if r == NoAction {
return ""
}
return strings.Replace(strings.Title(strings.ToLower(string(r))), " ", "", -1)
return strings.ReplaceAll(strings.Title(strings.ToLower(string(r))), " ", "")
}
// Index definition for table index.