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

sql: type error when specifying decimal precision #4650

Closed
Linicks opened this issue Feb 25, 2016 · 2 comments
Closed

sql: type error when specifying decimal precision #4650

Linicks opened this issue Feb 25, 2016 · 2 comments
Milestone

Comments

@Linicks
Copy link
Contributor

Linicks commented Feb 25, 2016

All,
In the following example I'm getting a type error when trying to specify the decimal precision. Here are the details:

create database bookstore;


set database = bookstore;


CREATE TABLE books (
-> isbn char(14) NOT NULL,
-> title varchar(255) NOT NULL,
-> author varchar(255) NOT NULL,
-> price decimal(5,2) NOT NULL
-> );
CREATE TABLE


INSERT INTO books (isbn, title, author, price) VALUES
-> ('978-1503261969', 'Emma', 'Jayne Austen', 9.44),
-> ('978-1505255607', 'The Time Machine', 'H. G. Wells', 5.99),
-> ('978-1503379640', 'The Prince', 'Niccolò Machiavelli', 6.99);
pq: value type float doesn't match type DECIMAL of column "price"


Postgresql reference docs: http://www.postgresql.org/docs/current/static/datatype-numeric.html

@petermattis petermattis changed the title Type error when specifying decimal precision sql: type error when specifying decimal precision Feb 25, 2016
@petermattis
Copy link
Collaborator

Our type inference/conversion is still a work in progress. At the moment you'll have to manually insert cast statements (with the realization that you've actually lost precision). Something like:

INSERT INTO books (isbn, title, author, price) VALUES 
    ('978-1503261969', 'Emma', 'Jayne Austen', CAST(9.44 AS DECIMAL));

We're working on fixing this.

@petermattis petermattis added this to the 1.0 milestone Feb 29, 2016
@petermattis petermattis modified the milestones: 1.0, Q2, Beta Apr 6, 2016
@nvanbenschoten
Copy link
Member

This all seems to be working with the new typing system #6358.

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

4 participants