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

fix(entity-generator): optional and hidden properties get type option + string defaults #5264

Merged
merged 1 commit into from
Feb 21, 2024

Conversation

boenrobot
Copy link
Collaborator

@boenrobot boenrobot commented Feb 20, 2024

The "default" option is no longer emitted into the decorator, in favor of it being specified in the property's declaration at the entity class. The "defaultRaw" option is still used in cases where the SQL expression does not unambiguously map to the "default" option's value.

The MySQL schema helper translates TINYINT(1) with a value of 0 to "false". This ensures behavior consistent with other drivers. And if this value accidentally finds its way back in a query, it is also OK, as MySQL treats this literal as "0".

The "optional" option is now added early, in the DatabaseTable stage. This has also unlocked some ManyToMany relations that were previously not detected.

Closes #5260

@boenrobot boenrobot force-pushed the differentButStillTheSameDefaultOptionals branch from ae6e135 to 662fbda Compare February 20, 2024 22:06
@boenrobot
Copy link
Collaborator Author

The branch is on top of #5254.

I thought I shouldn't amend that other one, because review would be harder... but at the same time, changes are substantial enough, that I can't exactly do them from master without that other one in...

@boenrobot boenrobot force-pushed the differentButStillTheSameDefaultOptionals branch 5 times, most recently from 1282629 to 0b4d9a7 Compare February 21, 2024 16:07
Base automatically changed from iUnsignedAndGen to master February 21, 2024 19:23
… + string defaults

The "default" option is no longer emitted into the decorator,
in favor of it being specified in the property's declaration at the entity class.
The "defaultRaw" option is still used in cases where the SQL expression does not unambiguously map
to the "default" option's value.

The MySQL and MariaDB schema helper translates TINYINT(1) with a values of 0 or 1
to "false" or "true", respectively.
This ensures behavior consistent with other drivers.
And if this value accidentally finds its way back in a query, it is also OK,
as MySQL and MariaDB treat those literals as those number literals.

The "optional" option is now added early, in the DatabaseTable stage.
This has also unlocked some ManyToMany relations that were previously not detected.

Closes #5260
@boenrobot boenrobot force-pushed the differentButStillTheSameDefaultOptionals branch from 0b4d9a7 to 037efaf Compare February 21, 2024 19:55
Copy link

codecov bot commented Feb 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d78da29) 99.74% compared to head (037efaf) 99.74%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5264   +/-   ##
=======================================
  Coverage   99.74%   99.74%           
=======================================
  Files         222      222           
  Lines       16855    16856    +1     
  Branches     4110     4117    +7     
=======================================
+ Hits        16812    16813    +1     
  Misses         43       43           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@boenrobot boenrobot marked this pull request as ready for review February 21, 2024 20:04
Copy link
Member

@B4nan B4nan left a comment

Choose a reason for hiding this comment

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

strictly speaking, we dont need the explicit type when we have the property initializer, but it wont hurt to have it there, lets keep it

@B4nan B4nan merged commit 12d3b54 into master Feb 21, 2024
11 checks passed
@B4nan B4nan deleted the differentButStillTheSameDefaultOptionals branch February 21, 2024 20:31
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.

property: Date & Opt; translates to varchar in migration
2 participants