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

Milliseconds being Trimmed on SQL queries. #22048

Closed
kevupton opened this issue Nov 12, 2017 · 5 comments
Closed

Milliseconds being Trimmed on SQL queries. #22048

kevupton opened this issue Nov 12, 2017 · 5 comments

Comments

@kevupton
Copy link

kevupton commented Nov 12, 2017

  • Laravel Version: 5.5.*
  • PHP Version: 7.1.9
  • Database Driver & Version: ibmysql - mysqlnd 5.0.12-dev - 20150407 - $Id: b396954eeb2d1d9ed7902b8bae237b287f21ad9e $

Description:

When I select TIME(3) from the database the resulting millisecond precision is trimmed from the data.

Steps To Reproduce:

  1. Create a column which is of type TIME(3).
  2. Create some datasets for this field, with millisecond precision.
  3. Run a SELECT MAX(time) max, MIN(time) time FROM table. Using the \DB Facade. (Either query builder or not).
  4. var_dump the results.
  5. Notice how the precision has been trimmed from the time fields.

Note: I figured this is laravel specific, because when I run a raw php script. Which simply does the same thing, (outside of laravel) the result contains the precision. It also works in phpmyadmin.

@Dylan-DPC-zz
Copy link

Which minor (last number in version) version are you on? #21936 might have fixed your issue

@paulofreitas
Copy link
Contributor

paulofreitas commented Nov 12, 2017

@Dylan-DPC Actually #21936 haven't fixed this issue because currently no schema grammar honor the given precision. See #22004 #22122.

@kevupton Currently all schema grammars are ignoring any given precision in time() and timeTz() columns.

It should be noted, however, that the MySQL version you're using does not support the TIME(fsp) syntax, this is available only to MySQL 5.6.4 and up: https://dev.mysql.com/doc/relnotes/mysql/5.6/en/news-5-6-4.html

This is the current behavior:

Grammar Compiled SQL Column Precision Behavior
MySQL time 0 Lacks handling custom precisions
Should be using time($column->precision)
PostgreSQL time(0) 0 Lacks handling custom precisions
Should be using time($column->precision)
SQLite time 0 Fine (SQLite does not support column precisions)
SQL Server time 7 Uses the default database precision (7)
Lacks handling custom precisions
Should be using time($column->precision) to both support custom precisions and use a default of 0

These and a few other changes have been proposed in #22004 to fix all unexpected behaviors - unfortunately this PR targets Laravel 5.6 because it's arguable this is breaking change (even the current behavior being somewhat broken).

This was implemented in #22122 and should be included with Laravel 5.5.22 when released. 😉

@kevupton
Copy link
Author

Dam ok, thanks. I will just do a manual workaround for now.

@paulofreitas
Copy link
Contributor

@kevupton This was implemented in #22122 and should be included with Laravel 5.5.22 when released. 😉

Do you mind closing this issue now that it got resolved? Thanks for reporting this, it was helpful to get this functionality implemented. 👍

@kevupton
Copy link
Author

Woo ! Awesome, look forward to the release. 🥇

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

No branches or pull requests

3 participants