MCPcopy Create free account
hub / github.com/temporalio/temporal / parseSQLStmts

Method parseSQLStmts

tools/common/schema/updatetask.go:227–249  ·  view source on GitHub ↗
(fsys fs.FS, dir string, manifest *manifest)

Source from the content-addressed store, hash-verified

225}
226
227func (task *UpdateTask) parseSQLStmts(fsys fs.FS, dir string, manifest *manifest) ([]string, error) {
228 result := make([]string, 0, 4)
229
230 for _, file := range manifest.SchemaUpdateCqlFiles {
231 schemaPath := path.Join(dir, file)
232 task.logger.Info("Processing schema file: " + schemaPath)
233 schemaBuf, err := fs.ReadFile(fsys, schemaPath)
234 if err != nil {
235 return nil, fmt.Errorf("error reading file %s: %w", schemaPath, err)
236 }
237 stmts, err := persistence.LoadAndSplitQueryFromReaders([]io.Reader{bytes.NewBuffer(schemaBuf)})
238 if err != nil {
239 return nil, fmt.Errorf("error parsing file %v, err=%v", schemaPath, err)
240 }
241 result = append(result, stmts...)
242 }
243
244 if len(result) == 0 && !manifest.AllowNoCqlFiles {
245 return nil, fmt.Errorf("found 0 updates in dir %v", dir)
246 }
247
248 return result, nil
249}
250
251func validateCQLStmts(stmts []string) error {
252 for _, stmt := range stmts {

Callers 1

buildChangeSetMethod · 0.95

Calls 4

InfoMethod · 0.65
ReadFileMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected