MCPcopy Create free account
hub / github.com/AdRoll/baker / renderSQLitePathString

Function renderSQLitePathString

output/sqlite.go:85–108  ·  view source on GitHub ↗
(pathString string, shardID int, field string)

Source from the content-addressed store, hash-verified

83}
84
85func renderSQLitePathString(pathString string, shardID int, field string) (string, error) {
86 // This function substitutes {{ShardId}} and {{Field}} in PathString.
87 var templ *template.Template
88 var doc bytes.Buffer
89 replacementVars := map[string]string{
90 "ShardId": fmt.Sprintf("%04d", shardID),
91 "Field": field,
92 }
93
94 templ, err := template.New("sqlite").Parse(pathString)
95 if err != nil {
96 return "", err
97 }
98
99 err = templ.Execute(&doc, replacementVars)
100 if err != nil {
101 return "", err
102 }
103 dir := doc.String()
104 if dir == "" {
105 return "", fmt.Errorf("empty rendered path template")
106 }
107 return dir, nil
108}
109
110// runSQLCommands is an helper function that will run some commands on an SQL transaction.
111func runSQLCommands(tx *sql.Tx, commands []string) error {

Callers 1

NewSQLiteFunction · 0.85

Calls 2

ParseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected