Menu

#578 Round function doesn't work with SQLite3

4.3.1
closed-fixed
nobody
5
2018-01-23
2017-10-19
Pablo
No

When I execute SQL command select round(vcc,2) as vcc2 from tab; from Adminer, vcc2's column values (type real) are not rounded. When I execute the same SQL command from my Nodejs app, sqlite3 command line or even my own PHP app, it is ok.
I use login-sqlite plugin, tested on PHP 7.1.8 and PHP 5.6.31

Discussion

  • Jakub Vrána

    Jakub Vrána - 2018-01-22
    • status: open --> closed-wont-fix
     
  • Jakub Vrána

    Jakub Vrána - 2018-01-22

    This is not specific to Adminer, PHP does this. My guess is that the field is transferred as float which is unprecise.

     
  • Pablo

    Pablo - 2018-01-22

    How this could be PHP related when my own PHP script below is working fine?

    <?php
    $db = new SQLite3('iot.db');
    
    $results = $db->query('select round(vcc,2) as vcc2 from tab;');
    while ($row = $results->fetchArray()) {
        var_dump($row);
    }
    ?>
    

    While "select round(vcc,2) as vcc2 from tab;" in Adminer is not working (values are not rounded).

     

    Last edit: Pablo 2018-01-22
  • Jakub Vrána

    Jakub Vrána - 2018-01-23

    Adminer sets precision to 20.

     
  • Jakub Vrána

    Jakub Vrána - 2018-01-23
    • status: closed-wont-fix --> closed-fixed
     
  • Jakub Vrána

    Jakub Vrána - 2018-01-23

    I've decreased the display precision to 17 which is the PHP's internal float precision.

     

Log in to post a comment.