We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
How to add a custom type that would be not causing an error Formater? This is the interface?
ex.
CREATE TABLE objects ( object_id serial NOT NULL PRIMARY KEY, tags text[], ); INSERT INTO objects(tags) VALUES ('{a, b, c}'), ('{a, c}'), ('{c}'), ('{b}');
var model = struct { ObjectId int64 Tags StringSlice }{} QueryOne(&model, "SELECT object_id, tags FROM objects WHERE object_id = ?", 1) // ok model.Tags.Del("a") model.Tags.Del("b") model.Tags.Add("d") QueryOne(&model, "UPDATE objects SET tags = ?tags WHERE object_id = ?object_id", model) QueryOne(&model, "UPDATE objects SET tags = ? WHERE object_id = ?", model.Tags, model.ObjectId) // Error: Format(unsupported StringSlice) QueryOne(&model, "UPDATE objects SET tags = ? WHERE object_id = ?", []string(model.Tags), model.ObjectId) // It'ok, but isn't convenient to use
type StringSlice []string func (c *StringSlice) Del(str string) { str = strings.TrimSpace(str) if !c.IsExist(str) { return } for index, value := range *c { if bytes.Equal([]byte(str), []byte(value)) { (*c)[index] = (*c)[len((*c))-1] (*c) = (*c)[:len((*c))-1] return } } } func (c *StringSlice) IsExist(str string) bool { str = strings.TrimSpace(str) for _, value := range *c { if bytes.Equal([]byte(str), []byte(value)) { return true } } return false } func (c *StringSlice) Add(str string) { str = strings.TrimSpace(str) if len(str) == 0 { return } if !c.IsExist(str) { *c = append(*c, str) } }
The text was updated successfully, but these errors were encountered:
0c20ab7
Merge pull request #90 from go-pg/fix/issue-87
a822c69
Fix slice alis decoding. Fixes #87.
@gebv should be fixed in master. Thanks for the report!
Sorry, something went wrong.
vmihailenco
No branches or pull requests
How to add a custom type that would be not causing an error Formater? This is the interface?
ex.
The text was updated successfully, but these errors were encountered: