0
votes

Versions:

  • Firebird 3.0 with PDO
  • Laravel 7

I'm using the Eloquent and I'm using package for connection with database https://packagist.org/packages/harrygulliford/laravel-firebird.

OBS: In Windows Serve work very well, but in Linux don't (In CentOS 7 and Ubuntu Server 20.04LTS).

I'm using Laravel with Firebird and I've problems with fields of type NUMERIC that return wrong values.

Example: A query that should turn back 190,65, returns 0.0001.

This is the SQL DDL:

Item::selectRaw("CODIGO,DESCRICAO,PRECOVAREJO,PRECOATACADO,PRECOESPECIAL")->get(); 

This is return in json:

{ "data": [ { "CODIGO": "123456", "DESCRICAO": "DESCRIPTION EXAMPLE", "PRECOVAREJO": "0.0001", "PRECOATACADO": "0.0001", "PRECOESPECIAL": "0.0001" } ] } 

Create Table:

CREATE TABLE ITENS ( PRECOVAREJO NUMERIC(15,3), PRECOATACADO NUMERIC(15,3), PRECOESPECIAL NUMERIC(15,3), CODIGO VARCHAR(8) NOT NULL, DESCRICAO VARCHAR(80) );

enter image description here

Image example return using Postman

@Mark Rotteveel This is the query builded by Eloquent Laravel:

array:2 [ 0 => array:3 [ "query" => "select count(*) as "aggregate" from "ITENS" where "ITENS"."DATACANCELAMENTO" is null" "bindings" => [] "time" => 33.17 ] 1 => array:3 [ "query" => """select CODIGO, DESCRICAO, PRECOVAREJO, PRECOATACADO, PRECOESPECIAL from "ITENS" where "ITENS"."DATACANCELAMENTO" is null order by "CODIGO" asc fetch first 10 rows only """ "bindings" => [] "time" => 8.39 ] ]

This is return expected Image return expected

1
Please provide a minimal reproducible example. Your screenshots don't really help without the actual DDL, sample data and the query or code producing the wrong results. - Mark Rotteveel
Please include sample data, and if possible, the actual query that Laravel generated. - Mark Rotteveel
you can use TraceAPI on Firebird 2.5 or newer to see the real query. IBExpert or free FBProfiler.sf.net and perhaps many other GUI tools can use TraceAPI and log the SQL statements for you - Arioch 'The
@JosiasFonseca What is the point of notifying me if you haven't updated your question with the details I asked for? - Mark Rotteveel
I updated in question with the query that the builded by Eloquent and return of the database expected - Josias Fonseca

1 Answers

0
votes

I solved the problem by updating the PHP version to version 7.4.16. The problem was resolved in version 7.4.0

I also created a file in /etc/php.d/30-pdo_firebird.ini with the content: extension = pdo_firebird.

https://www.php.net/ChangeLog-7.php#7.4.0 resolve the bug https://bugs.php.net/bug.php?id=65690

Thanks to everyone who helped