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

[5.5] Add precision to dateTime and timestamp column types #18847

Merged
merged 3 commits into from
Apr 21, 2017

Conversation

dschniepp
Copy link
Contributor

@dschniepp dschniepp commented Apr 18, 2017

Regarding to issues like #3506 and #11239 I would like to propose a grammar change which allows to set the precision of dateTime and timestamp fields.

  • MySQL fully supported
  • PostgreSQL fully supported
  • SQLite has no date time
  • MSSQL unfortunately I can't test it.

The maximum granularity of the fractional seconds depends on the RDMS.

@@ -544,22 +544,24 @@ protected function typeDate(Fluent $column)
* Create the column definition for a date-time type.
*
* @param \Illuminate\Support\Fluent $column
* @param int
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@param int $precision

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I missed that.

@taylorotwell
Copy link
Member

None of these changes appear to actually let the user change the precision?

@dschniepp
Copy link
Contributor Author

dschniepp commented Apr 20, 2017

Sorry was my bad forgot to tweak the Blueprint Class. Now the user should be able to set the fractional seconds on the datetime and timestamp columns and also on the related functions like timestamps(), softDeletes() etc.

@fernandobandeira
Copy link
Contributor

fernandobandeira commented Apr 20, 2017

Actually on Sqlserver datetime(3) isn't supported, you can check the docs here

You can change that to use datetime2 it's available since sqlserver 2008, check the docs here wih this you'll be able to make it work since it support fractional seconds precision.

@dschniepp
Copy link
Contributor Author

Is it necessary to support SQL Server versions below SQL Server 2008?

@taylorotwell taylorotwell merged commit 5708e11 into laravel:master Apr 21, 2017
@dschniepp
Copy link
Contributor Author

@taylorotwell is it necessary to support SQL Server versions below SQL Server 2008 if not I would change the column type to datetime2 like @fernandobandeira proposed.

@chkm8
Copy link

chkm8 commented Jun 29, 2017

Hi, I just want to ask if this update about from datetime to datetime2 will be available on the next version or will be available in 5.4? Just wanted to know so that we could think a work around while waiting for the updates. Thanks.

@fernandobandeira
Copy link
Contributor

@chkm8 I've pushed it to 5.5. On #18962

@chkm8
Copy link

chkm8 commented Jun 29, 2017

Oh I see, thanks @fernandobandeira, will just wait until 5.5 is released next month.

@taylorotwell
Copy link
Member

This breaks support for MySQL 5.5? Do we want to revert?

@dschniepp
Copy link
Contributor Author

dschniepp commented Aug 1, 2017

I wouldn't revert it but make the precision configurable like @fernandobandeira on #20262 (comment) already proposed.

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

Successfully merging this pull request may close these issues.

5 participants