Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Query::addDefaultTypes() do what it says.
Instead of adding, addDefaultTypes() was replacing. While this is useful, adding is more useful as we want the typemap to accumulate type information throughout its lifetime.
- Loading branch information
Showing
2 changed files
with
19 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2400cf2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markstory I have two confirms in line:92.
Confirm
(1) If $types has same keys with $this->_defaults, $this->_defaults will not be overwritten by $types.
Because left operand has a priority than right operand in "array + array".
If $types can overwrite same keys, must be as follow.
(2) When called addDefaults(), $this->_defaults is possible to be null.
Because it is not initialized in line:31.
Next code makes error, therefore line:92 has possibility to throw error.
It is required to cast as array variables for avoiding error.
If can not happen that $this->_defaults and $types are null, it is not required to cast.
Suggestion
If (1) (2) is right, should be as follow
If use to initialize on line:31, to cast array for $this->_defaults is not required in my code.
However it makes very wide side effect.
2400cf2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The _defaults array is initialized in the constructor so it should never be null.
I didn't want to overwrite existing types with addDefaults() because I saw the method as an additive process that should preserve the existing table keys.
Overwriting keys may cause issues where tables have columns of the same name but the types are different. I felt it was safer to stick with the first values in.
2400cf2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@markstory Thank you for reply.
I cleared it. It is very important to know the thinking of other creators for such this huge project.