db icon indicating copy to clipboard operation
db copied to clipboard

Support DateTime instances

Open Tigrov opened this issue 2 years ago • 2 comments

Some comments are left for review and will be removed after.

ColumnSchema::dateTimeFormat() and ColumnSchema::$dateTimeFormat can be removed, in this case it will be necessary to determine the format from ColumnSchema each time when casting values.

Update 09.08.2023

ColumnSchema::hasTimezone() can be replaced with two new abstract types SchemaInterface::TYPE_TIMESTAMPTZ and SchemaInterface::TYPE_TIMETZ

Both options (remove methods) can be done without loss of performance if type casting will be optimized as here #737

Q A
Is bugfix?
New feature? ✔️
Breaks BC? ✔️
Fixed issues #725

Tigrov avatar Aug 05 '23 13:08 Tigrov

PR Summary

  • Addition of dateTimeFormat property in AbstractColumnSchema class A new setting has been added to our digital blueprint for columns (AbstractColumnSchema class). This new addition allows us to specify the format in which dates and times will be presented when changing from DateTimeInterface to a format that fits into databases. This is achieved with two new features dateTimeFormat() and getDateTimeFormat().

  • New method getDateTimeFormat() in AbstractSchema class A new feature has been incorporated into our main blueprint (AbstractSchema class) which fetches the date and time format according to the type of column we are dealing with.

  • Introduction of dateTimeFormat() method to ColumnSchemaInterface interface We've added a new approach in our contract (ColumnSchemaInterface interface) for setting up column types. The function, dateTimeFormat(), will now set the date and time format specifically for each column type.

  • Creation of PHP_TYPE_DATE_TIME constant in SchemaInterface interface A new constant label PHP_TYPE_DATE_TIME has been included in our blueprint (SchemaInterface), which represents the PHP type DateTimeInterface.

  • New tests in CommonSchemaTest class Lastly, we've added checks in our testing class (CommonSchemaTest) to confirm the correctness of the new date and time format feature.

what-the-diff[bot] avatar Aug 05 '23 13:08 what-the-diff[bot]

Codecov Report

Attention: Patch coverage is 97.91667% with 1 line in your changes missing coverage. Please review.

Project coverage is 89.76%. Comparing base (c5aa0b1) to head (e71d368). Report is 175 commits behind head on master.

Files with missing lines Patch % Lines
src/Schema/AbstractColumnSchema.php 96.00% 1 Missing :warning:
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #736      +/-   ##
============================================
+ Coverage     89.59%   89.76%   +0.16%     
- Complexity     1375     1396      +21     
============================================
  Files            67       67              
  Lines          3382     3428      +46     
============================================
+ Hits           3030     3077      +47     
+ Misses          352      351       -1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Aug 05 '23 13:08 codecov[bot]