Last active
January 18, 2024 00:53
-
-
Save kyleconroy/11e58b9480f97d838cc04793dc07005a to your computer and use it in GitHub Desktop.
Numerics in pgx/v5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"github.com/jackc/pgx/v5/pgtype" | |
) | |
func main() { | |
var num pgtype.Numeric | |
if err := num.Scan(updateCustomerObj.DiscountPercentage); err != nil { | |
fmt.Println(err) | |
return | |
} | |
sqlc.UpdateCustomersParams{ | |
SetDiscountPercentage: !(updateCustomerObj.DiscountPercentage == 0), | |
DiscountPercentage: *num | |
} | |
fmt.Printf("output: %s", output) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment