Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(inputs): Fix string encoding as paramters #190

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

julienbourdeau
Copy link
Contributor

@julienbourdeau julienbourdeau commented Jul 8, 2024

In Go, when a string attribute is explicitly noted at string for serialization, outer quotes are added ". I have no idea if it's intentional, but probably.

Typically, the WalletListInput.ExternalCustomerID will result in this URL:

/api/v1/wallets?external_customer_id=%22julien%22

Hence, the external_id we look for the DB is "julien", not julien.

SELECT
	"customers".*
FROM
	"customers"
WHERE
	"customers"."deleted_at" IS NULL
	AND "customers"."organization_id" = "external_id"
	AND "customers"."external_id" = "\"julien\""
LIMIT 1

Example

package main

import (
	"encoding/json"
	"fmt"
)

type Interesting struct {
	Quoted    string `json:"quoted,omitempty,string"`
	NotQuoted string `json:"not_quoted,omitempty"`
}

func main() {
	strings := Interesting{"lago", "lago"}
	fmt.Println(strings)
	fmt.Println()

	jsonStr, _ := json.Marshal(strings)
	fmt.Println(string(jsonStr))
	fmt.Println()

	asMap := make(map[string]string)
	json.Unmarshal(jsonStr, &asMap)
	fmt.Println(asMap)
}
$ go run main.go
{lago lago}

{"quoted":"\"lago\"","not_quoted":"lago"}

map[not_quoted:lago quoted:"lago"]

@julienbourdeau julienbourdeau merged commit 59a7cd6 into main Jul 8, 2024
1 check passed
@julienbourdeau julienbourdeau deleted the fix/string-quote branch July 8, 2024 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants