Skip to content

Commit

Permalink
fix issue #111 (#112)
Browse files Browse the repository at this point in the history
* fix issue #111
  • Loading branch information
felix-schott authored Dec 12, 2024
1 parent 435a8c5 commit 025963a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion backend/cmd/dbcli/cli_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func TestCli(t *testing.T) {
testSessionProps := types.SessionProperties{
SessionName: ptr("Foo's Session"),
Venue: ptr(int32(-999999)), // replace this after serialisation
Description: ptr("Bla bla"),
Description: ptr("A wise man once said: \"Bla bla\""),
StartTimeUtc: ptr(time.Date(2024, 5, 7, 1, 1, 1, 1, time.UTC)),
DurationMinutes: ptr(int16(30)),
Interval: ptr(types.Weekly),
Expand Down
9 changes: 5 additions & 4 deletions backend/internal/migrations/migrations.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ func WriteMigration(cmd string, title string, migrationsDirectory string) (strin
if len(subCmd) != 0 {
arr := strings.Split(subCmd, `"`)
newArr := make([]string, 3)
newArr[0] = arr[0] // everything up to the start of the json body
newArr[1] = strings.Join(arr[1:len(arr)-1], `\"`) // the json payload, here we escape all "
newArr[2] = arr[len(arr)-1] // end
subCmds[idx] = strings.Join(newArr, `"`) // overwrite subcmd with the substituted string
newArr[0] = arr[0] // everything up to the start of the json body
newArr[1] = strings.Join(arr[1:len(arr)-1], `\"`) // the json payload, here we escape all "
newArr[1] = strings.ReplaceAll(newArr[1], `\\"`, `\\\"`) // " in the field values (e.g. speech marks) needs to be triple escaped ///"
newArr[2] = arr[len(arr)-1] // end
subCmds[idx] = strings.Join(newArr, `"`) // overwrite subcmd with the substituted string
}
}
cleanCmd := strings.Join(subCmds, ";") // join back together
Expand Down

0 comments on commit 025963a

Please sign in to comment.