dbcli/pgcli

Numeric output is not showed correctly

Opened this issue · 10 comments

I'm using pgcli version: 1.3.1

This is the output using pgcli:
1480184973

And the output for the same query, using psql:
1480184890


This is a better test that anyone can replicate:

pgcli:
1480185134

psql:
1480185172


The behavior is new; at least 4 months ago it was working as intended.

I didn't found any relevant commit that could change that behaivour, just this one: #591

Formatting in pgcli is done by tabulate. Pgcli keeps its own slightly tweaked version of tabulate here. Tabulate tries to be smart about formatting numbers.

>>> print tabulate.tabulate([['x'], [1.00000000]], headers='firstrow')[0]
  x
---
  1

Thank you, @j-bennet, I'll give it a check.

I'm not sure what the good solution is here, have to think about it. In a lot of cases, "simplifying" numbers like tabulate does is a good thing, but not when you explicitly format it to certain precision.

Maybe putting an option in the configuration file to turn off numeric_simplification.

Also, it would be nice to have a bullet about this simplification in the features section.

Just spend a couple of hours trying to figure out why values become rounded. This option (or at least explicitly explain this behaviour on README.md) could be helpful!

👍 thanks!

shaib commented

Hi, I got to this issue from the readme, where I'm guessing it shouldn't be mentioned anymore...

@shaib good catch - thanks!