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

sqlsrv omits leading zeros for decimal/float values #881

Closed
Jeeppler opened this issue Nov 14, 2018 · 4 comments
Closed

sqlsrv omits leading zeros for decimal/float values #881

Jeeppler opened this issue Nov 14, 2018 · 4 comments

Comments

@Jeeppler
Copy link

PHP Driver version or file name

sqlsrv 5.3.0 PECL

SQL Server version

SQL Server 2016 Standard

Client operating system

Ubuntu LTS 18.04

PHP version

PHP 7.2 - From official Ubuntu 18.04 repositories

Microsoft ODBC Driver version

msodbcsql17/bionic,now 17.2.0.1-1 amd64 (MD5sum: 0a13d93b2af7a0383f93d71448feb0a4)

Problem description

We upgraded from the deprecated mssql PHP driver to sqlsrv. Our application is written in PHP + Symfony and uses Doctrine to communicate to SQL Server. The platform we are on is Ubuntu 18.04 (after upgrading). Everything works, except for zero decimal/float values. The issue is that the sqlsrv driver omits leading zeros. Values which are in the dabase 0.00 will be fetched as .00.

Actual behavior

sqlsrv driver omits leading zeros in front of decimal/float values.

For example:

  • In the database: 0.00.
  • After retrieving the value: .00 in PHP application.

Expected behavior

sqlsrv driver does not omit leading zeros.

Float/decimal values should be returned with leading zeros.

For example:

  • In the database: 0.00.
  • After retrieving the value: 0.00 in PHP application.

Related

Driver omitting leading zero in decimal

@yitam
Copy link
Contributor

yitam commented Nov 14, 2018

Hello @Jeeppler

This is by design and related to a feature request discussed in #415.

New configuration options to format outputs for decimal and numeric for both sqlsrv and pdo_sqlsrv have been recently implemented. Please stay tuned for the release of our next preview to try this out.

@Jeeppler
Copy link
Author

Jeeppler commented Nov 14, 2018

@yitam are you referring to this pull request: #861 ?

@yitam
Copy link
Contributor

yitam commented Nov 14, 2018

@Jeeppler we merged two pull requests (#861 and #873). The changes only applied to decimal and/or numeric types because they are always fetched as strings, unlike floats or integers, which can be fetched as numbers.

@yitam
Copy link
Contributor

yitam commented Dec 7, 2018

@Jeeppler closing this issue as it is closely related to #415

@yitam yitam closed this as completed Dec 7, 2018
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

2 participants