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

Use null coalescing operator instead of isset #545

Merged
merged 2 commits into from
Apr 8, 2020
Merged

Conversation

mvorisek
Copy link
Member

@mvorisek mvorisek commented Apr 8, 2020

No description provided.

@mvorisek mvorisek force-pushed the simplify_isset branch 2 times, most recently from 5720a5c to 16437ad Compare April 8, 2020 11:03
@codecov
Copy link

codecov bot commented Apr 8, 2020

Codecov Report

Merging #545 into develop will increase coverage by 0.48%.
The diff coverage is 83.33%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop     #545      +/-   ##
=============================================
+ Coverage      86.47%   86.95%   +0.48%     
+ Complexity      1252     1232      -20     
=============================================
  Files             28       28              
  Lines           2720     2730      +10     
=============================================
+ Hits            2352     2374      +22     
+ Misses           368      356      -12     
Impacted Files Coverage Δ Complexity Δ
src/Model.php 91.03% <ø> (ø) 376.00 <0.00> (-1.00)
src/Reference.php 86.53% <0.00%> (ø) 27.00 <4.00> (ø)
src/Field.php 78.52% <69.23%> (-0.27%) 95.00 <26.00> (-4.00)
src/Field/Boolean.php 86.95% <100.00%> (ø) 15.00 <3.00> (ø)
src/Field_SQL_Expression.php 94.44% <100.00%> (ø) 9.00 <1.00> (ø)
src/Persistence.php 85.52% <100.00%> (+6.57%) 86.00 <0.00> (-1.00) ⬆️
src/Persistence/Array_.php 91.76% <100.00%> (+0.09%) 65.00 <0.00> (-5.00) ⬆️
src/Persistence/SQL.php 77.12% <100.00%> (+0.25%) 189.00 <0.00> (-5.00) ⬆️
src/Reference/HasMany.php 89.39% <100.00%> (ø) 31.00 <0.00> (-4.00)
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e5dba07...f7b1bbf. Read the comment docs.

@mvorisek
Copy link
Member Author

mvorisek commented Apr 8, 2020

There is a small bug - see https://github.com/atk4/data/runs/570500993

@DarkSide666 How to solve it?

@DarkSide666 DarkSide666 self-requested a review April 8, 2020 12:54
Copy link
Member

@DarkSide666 DarkSide666 left a comment

Choose a reason for hiding this comment

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

Overall looks good. I will check why value type is cast in this case. I guess ?? does that somehow.

@mvorisek
Copy link
Member Author

mvorisek commented Apr 8, 2020

Overall looks good. I will check why value type is cast in this case. I guess ?? does that somehow.

No, see the 2nd reverted commit - the issue is that the return type is now forced to string (by function header). Probably the export function should not use toString for numerical fields.

@DarkSide666
Copy link
Member

No, see the 2nd reverted commit - the issue is that the return type is now forced to string (by function header). Probably the export function should not use toString for numerical fields.

Oh I see. Well... I think toString should return string always, so maybe we should change tests anxd cast everything to string. I think it will not affect anything important because it still will be var_dump("5"+3); int 8

@mvorisek
Copy link
Member Author

mvorisek commented Apr 8, 2020

@DarkSide666 Done, same assumption on my side, but the test data come from export method and I think this method should preserve the integer type.

Any idea how to fix this properly, i.e. without changing the test data?

@DarkSide666
Copy link
Member

No idea, but I think it's OK this way.
If we want typecasted export, then there is 3rd parameter of export method. Otherwise it's not typecasted - so doing toString.
These vat_rate_id fields are not actually id fields. They are not defined as hasOne fields I think.

@mvorisek mvorisek merged commit 21c689b into develop Apr 8, 2020
@mvorisek mvorisek deleted the simplify_isset branch April 8, 2020 14:34
DarkSide666 added a commit that referenced this pull request Apr 8, 2020
* wip

* wip

* fixes

* Feature/test1 (#483)

* fixes

* testtisg

* wip

* test

* backmerge master

* normalize everything

* added locale test (#485)

* added locale test

* Apply fixes from StyleCI

* wip

* wip

* Apply fixes from StyleCI

* Update CHANGELOG.md

* Implement #386 (#477)

* Implement #386

* Apply fixes from StyleCI

* Update Field.php

* Update Model.php

* Update Helper.php

* Apply fixes from StyleCI

* move functionality to atk4/core

* Apply fixes from StyleCI

* fix traits

* Apply fixes from StyleCI

* fix typo

* Feature/pgsql test (#486)

* fix one test

* Setting current dependencies

* wip

* wip

* Add matrix testing (#492)

* Test using matrix

* wip

* wip

* wip

* clean up bundler

* clean up bundler (#493)

* wip

* Fix/delete callback (#488)

* fix one test

* Setting current dependencies

* fix/delete callback

* Update composer.json

* Fix/persistence sql condition (#487)

* fix one test

* Setting current dependencies

* fix wrong assignment of value as condition

* Update composer.json

* Update SQL.php

* Feature remove specified action (#489)

* fix one test

* Setting current dependencies

* add method to remove specified action(s) from model

* Update Model.php

* spaces

* Feature/add confirmation callback argument (#491)

* fix one test

* Setting current dependencies

* pass the action object as argument to confirmation callback

* badge

* Feature/set custom edit exec button (#490)

* fix one test

* Setting current dependencies

* use custom exec button on edit action

* Update Model.php

* remove class, use seed

Co-authored-by: Imants Horsts <[email protected]>

* model default add field property (#454)

* use the object default add field property

* no need for double brackets.

* force tests

Co-authored-by: Romans Malinovskis <[email protected]>
Co-authored-by: Imants Horsts <[email protected]>

* Fix empty array condition (#498)

* more tests

* Apply fixes from StyleCI

* better implementation for addFields() and test cases (#499)

* better implementation for addFields() and test cases

* Apply fixes from StyleCI

* use shorthand method

* simplify code

* implement `exprNow()` method. Rely on dsql PR.

* Apply fixes from StyleCI

* pass

* add docs

Co-authored-by: Romans Malinovskis <[email protected]>

* Fix/ Small Action related fix (#502)

* Fix/ Small Action related fix

- Set Edit action exec button labe lto 'Save' by default
 - Set Edit action exec button colot to blue by default
- Set default description for Add action in model
- Add method to retreive model from Action

* Apply fixes from StyleCI

* fix comment

Co-authored-by: Imants Horsts <[email protected]>

* update multiple delete example (#503)

* now supports multiple filter options in getFields()

* Apply fixes from StyleCI

* Accept any DateTimeInterface impl. for datetime (#505)

* Accept any DateTimeInterface impl. for datetime

* Fix DateTime::getTimezone method name

* Fix setTimezone for any instance of DateTimeInterface

* Add microseconds persistence support for datetime/time types + fix normalization/cloning issue (#504)

* Fix datetime normalization cloning

* Add microseconds persistence support for datetime/time types

Co-authored-by: Imants Horsts <[email protected]>

* include comment about hooks and example how to execute them (#510)

* update composer

* Update release-drafter.yml

* Update bundler.yml

* Fix hasOne relation seed processing. It should replace not merge. (#512)

* New method $model->getTitles() (#513)

* Implement `getTitles()` method

* Apply fixes from StyleCI

* Update unit-tests.yml

* migration to migrator

* rename addHook to onHook (#514)

* fix #944 (#516)

* allow dots in table names, fix #515, fix #517

* Apply fixes from StyleCI

* Do not fail-fast PHP test matrix (#522)

* Simplify code (#519)

* Update release-drafter.yml

* Update release-drafter.yml

* Fix hook trait usage (#525)

* Hook args must be an array

* Fix hook onHook() usage

* Implement addWith() (#527)

* Implement addWith()

* Apply fixes from StyleCI

* implement `addWith`

* add docs

* add note

* Update unit-tests.yml

* Update unit-tests.yml

* Update unit-tests.yml

* Update unit-tests.yml

* Update unit-tests.yml

* Update unit-tests.yml

* Update unit-tests.yml

* Update unit-tests.yml

* Update unit-tests.yml

* Update unit-tests.yml

* Update unit-tests.yml

* Action should also support `fields===true` value (#531)

* Fix LIKE conditions for Array and SQL persistences (#532)

* Fix LIKE conditions - fix fix (#535)

* fix #533 (#537)

* Fix value trim (#538)

* introduce sql null condition test (#540)

* introduce test on condition with null value

* include mesage in SQL exception details

* Fix typo

* Convert scalar class names to ::class (#544)

* Fix CS - do not import classes without namespace

* Use null coalescing operator instead of isset (#545)

* Use null coalescing operator instead of isset

* Fix tests

* Fix refactorability for "owner" (#543)

* Fix refactorability for "owner"

* Typehint for elements

* Narrow phpdoc for SQL subtypes

* Fix typos

* Setting release dependencies

Co-authored-by: Romans Malinovskis <[email protected]>
Co-authored-by: Romans Malinovskis <[email protected]>
Co-authored-by: Imants Horsts <[email protected]>
Co-authored-by: Georgi Hristov <[email protected]>
Co-authored-by: Mimo <[email protected]>
Co-authored-by: Alain Belair <[email protected]>
Co-authored-by: DarkSide <[email protected]>
Co-authored-by: Michael Voříšek <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants