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

How to define decimal precision using gorm & postgres? #6612

Closed
rngallen opened this issue Sep 22, 2023 · 2 comments
Closed

How to define decimal precision using gorm & postgres? #6612

rngallen opened this issue Sep 22, 2023 · 2 comments
Assignees
Labels
type:question general questions

Comments

@rngallen
Copy link

Your Question

How can I implement precision on decimals(float) using gorm?

type Abc struct {
FieldOne float64 gorm:"precision(8,2) // eight digits with 2 decimal places
}

The document you expected this should be explained

Expected answer

@rngallen rngallen added the type:question general questions label Sep 22, 2023
@akshay-pj-open
Copy link

akshay-pj-open commented Nov 9, 2023

Use column type as numeric(8,2) // Eight digits and Two decimal places.

Example:

type Abc struct {
FieldOne   float64  `gorm:"type:numeric(8,2)"`
}

@ravenrich
Copy link

how to define decimal(32,16)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:question general questions
Projects
None yet
Development

No branches or pull requests

4 participants