Skip to content

Conversation

Tigrov
Copy link
Member

@Tigrov Tigrov commented Jul 4, 2023

Q A
Is bugfix?
New feature?
Breaks BC?
Fixed issues

@what-the-diff
Copy link

what-the-diff bot commented Jul 4, 2023

PR Summary

  • Update to .gitignore file
    The .gitignore file, which dictates what types of files and directories to ignore, has been updated to include two more types (/phpunit.xml and /.phpunit.result.cache). This means these types will be excluded from the project repository.

  • Improvement to default value setting in Schema.php
    In the Schema.php file, part of the code that controls how to set default values for certain aspects has been restructured. A normalizeDefaultValue function is now used, promoting cleaner and more efficient code.

  • Addition of .gitignore in /tests/Support/Runtime directory
    A new .gitignore file has been added to the /tests/Support/Runtime directory. Like its sibling in the main project directory, this file will help ensure certain file and directory types in this specific area are omitted from the project repository.

@codecov
Copy link

codecov bot commented Jul 4, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (adeb178) 98.20% compared to head (893f367) 98.20%.

❗ Current head 893f367 differs from pull request most recent head 942033f. Consider uploading reports for the commit 942033f to get more accurate results

Additional details and impacted files
@@            Coverage Diff            @@
##             master     #260   +/-   ##
=========================================
  Coverage     98.20%   98.20%           
+ Complexity      327      323    -4     
=========================================
  Files            17       17           
  Lines          1003     1005    +2     
=========================================
+ Hits            985      987    +2     
  Misses           18       18           
Impacted Files Coverage Δ
src/Schema.php 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@Tigrov Tigrov marked this pull request as ready for review July 6, 2023 07:25
@terabytesoftw terabytesoftw added the status:code review The pull request needs review. label Jul 6, 2023
return $column;
return match ($defaultValue) {
null, 'null', '' => null,
'CURRENT_TIMESTAMP', 'CURRENT_DATE', 'CURRENT_TIME' => new Expression($defaultValue),
Copy link
Contributor

@darkdef darkdef Jul 9, 2023

Choose a reason for hiding this comment

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

Need add check for type of column. Without check type of column - with default value in column equal 'CURRENT_TIMESTAMP' (string), default value will be incorrect

Copy link
Member Author

Choose a reason for hiding this comment

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

There is no special date type timestamp or datetime in SQlite.
https://www.sqlite.org/datatype3.html

For this purpose text type can be used.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

We have dbtype in schema of column, and need check type in condition

Copy link
Member Author

Choose a reason for hiding this comment

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

Added test with STRICT table where TIMESTAMP type is not allowed but TEXT type for storing date and time is okey.

CREATE TABLE "timestamp_default" (
  id INTEGER PRIMARY KEY,
  text_col TEXT NOT NULL DEFAULT 'CURRENT_TIMESTAMP',
  timestamp_text TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP
) STRICT;

Could you show a test where current changes without check for type of column will fail?

Copy link
Contributor

Choose a reason for hiding this comment

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

test will be more reliable. Simply add test for column text_col with assert: defaultValue not instaceof Expression

Copy link
Contributor

Choose a reason for hiding this comment

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

The current test is sufficient. Make it work without errors and that's it. Thank you

return $column;
return match ($defaultValue) {
null, 'null', '' => null,
'CURRENT_TIMESTAMP', 'CURRENT_DATE', 'CURRENT_TIME' => new Expression($defaultValue),
Copy link
Contributor

Choose a reason for hiding this comment

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

We have dbtype in schema of column, and need check type in condition

Copy link
Contributor

@darkdef darkdef left a comment

Choose a reason for hiding this comment

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

Thanks. Please add line to changelog

@darkdef darkdef merged commit 032e1b3 into yiisoft:master Jul 13, 2023
@darkdef
Copy link
Contributor

darkdef commented Jul 13, 2023

Thanks

@Tigrov Tigrov deleted the typecast_refactoring branch July 17, 2023 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:code review The pull request needs review.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants