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

Columns with NUMERIC datatype do not return any value in the query #50

Closed
supermuka opened this issue May 2, 2018 · 6 comments · Fixed by isoos/postgresql-dart#7
Closed

Comments

@supermuka
Copy link

Consider the following columns and respectives datatypes on table auge_objective.measures:

id VARCHAR,
name VARCHAR,
start_value NUMERIC,
end_value NUMERIC,
current_value NUMERIC

When the query is executed the following way, the NUMERIC columns don't return nothing.

"SELECT id, name, start_value, end_value, current_value FROM auge_objective.measures ";

But if it's used cast to REAL, the query returns with right values. It´s works!

"SELECT id, name, start_value::REAL, end_value::REAL, current_value::REAL FROM auge_objective.measures ";

@itsjoeconway
Copy link
Contributor

itsjoeconway commented May 4, 2018

NUMERIC data type isn't supported. There isn't a Dart type that fits the requirements of numeric, so a Dart numeric type would have to be provided by this package. If you don't need the behavior of NUMERIC, prefer to use DOUBLE PRECISION or REAL.

@cardosodario
Copy link

but who has tables with thousands of data with the field NUMERIC and needs to access how to do without converting the tables

Does using a CAST work?

did anyone get an easy solution?

dario

@isoos
Copy link
Collaborator

isoos commented Jan 3, 2020

Casting to and from string usually worked for me. Maybe the (somewhat new?) BigInt core type could work for numeric? https://api.dart.dev/stable/2.7.0/dart-core/BigInt-class.html

@jcowgar
Copy link

jcowgar commented Jan 12, 2020

Numeric can have a decimal component. NUMERIC(12,2) for example.

@KarmaTensel
Copy link

Consider the following columns and respectives datatypes on table auge_objective.measures:

id VARCHAR,
name VARCHAR,
start_value NUMERIC, end_value NUMERIC, current_value NUMERIC

When the query is executed the following way, the NUMERIC columns don't return nothing.

"SELECT id, name, start_value, end_value, current_value FROM auge_objective.measures ";

But if it's used cast to REAL, the query returns with right values. It´s works!

"SELECT id, name, start_value::REAL, end_value::REAL, current_value::REAL FROM auge_objective.measures ";

what about timestamp? how do i return timestamp without time zone using casting? ::timestamp doesn't seem to work?

@atumn
Copy link

atumn commented Apr 19, 2021

I have encountered similar issue when I was working with graphql + ferry lib.
For what it's worth, I've serialized numeric to core/double using build_runner to generate my schemas. So far it's working okay.

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

Successfully merging a pull request may close this issue.

7 participants