Skip to content

Commit

Permalink
cmd/squibble: print digests on diff comparisons
Browse files Browse the repository at this point in the history
  • Loading branch information
creachadair committed Feb 16, 2024
1 parent 3588301 commit b576d08
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions cmd/squibble/squibble.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ must be a SQLite database. Use --sql to explicitly specify SQL input.
The output has the form:
db <hex> -- if the input was a SQLite database
sql <hex> -- if the input was a SQL schema file
db: <hex> -- if the input was a SQLite database
sql: <hex> -- if the input was a SQL schema file
`,
SetFlags: command.Flags(flax.MustBind, &digestFlags),
Run: command.Adapt(runDigest),
Expand Down Expand Up @@ -76,6 +76,16 @@ func runDiff(env *command.Env, dbPath, sqlPath string) error {
if err != nil {
return err
}
dbHash, err := squibble.DBDigest(env.Context(), db, "main")
if err != nil {
return err
}
sqlHash, err := squibble.SQLDigest(string(sql))
if err != nil {
return err
}
fmt.Println("db: ", dbHash)
fmt.Println("sql:", sqlHash)
if err := squibble.Validate(env.Context(), db, string(sql)); err != nil {
fmt.Println(err.(squibble.ValidationError).Diff)
return errors.New("schema differs")
Expand All @@ -93,7 +103,7 @@ func runDigest(env *command.Env, path string) error {
if err != nil {
return err
}
fmt.Println("sql", hash)
fmt.Println("sql:", hash)
return nil
}

Expand All @@ -107,7 +117,7 @@ func runDigest(env *command.Env, path string) error {
if err != nil {
return err
}
fmt.Println("db", hash)
fmt.Println("db: ", hash)
return nil
}

Expand Down

0 comments on commit b576d08

Please sign in to comment.