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

Server crashes when price is longer than 6 characters. #21

Open
2 tasks
fi-ya opened this issue Oct 7, 2021 · 0 comments
Open
2 tasks

Server crashes when price is longer than 6 characters. #21

fi-ya opened this issue Oct 7, 2021 · 0 comments

Comments

@fi-ya
Copy link

fi-ya commented Oct 7, 2021

Error: value too long for type character varying(6)

  • This error is created when you input a value more than 6 characters as its what you set in your init.sql file. You could either use MONEY data type or NUMERIC (see below for more info)
    product_price VARCHAR(6) NOT NULL,

Postgres provides ways to store monetary data, the Numeric type, and its alias, Decimal. These types can store numbers with a very large number of digits, and yet perform calculations exactly.

Postgres also offers a dedicated Money type which stores currency amounts with a fixed fractional precision.
The input can take many forms including integers, floats, and even strings such as ‘$20.00’. The output is also automatically formatted as a currency value.

For more information check out postgres docs on numeric types & money types

  • Not sure why you have a copy of init.sql file. You may want to delete it if you're not intending to use it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant