-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add support for custom types with requireSQLConversion and ResultSetMappingBuilder::generateSelectClause() #9326
Conversation
bba7a23
to
fe26dcc
Compare
Can you elaborate what this change does? |
When using ResultSetMappingBuilder::generateSelectClause() with custom types with Type::canRequireSQLConversion() => true, we would not call Type::convertToPHPValueSQL() to inject the required sql. I am trying to fix that here when using ResultSetMappingBuilder::*EntityFromClassMetadata() methods. ResultSetMappingBuilder can help with some of the pain of building native queries. There is still the case when using ResultSetMappingBuilder::addFieldResult() and etc which is not covered. i am affraid that changing those could maybe break peoples hacks out there. Not sure if i can/should fix thee psalm issues. Also could be nice if we could do this one place one day. I stole some of this from
PS. Sorry for jumping the gun with review request with failing tests. |
fe26dcc
to
d5e319a
Compare
Added test using addFieldResult(), works fine and i was wrong that *EntityFromClassMetadata() is a speciel case. |
@derrabus How do i solve the psalm issue? |
@kimhemsoe the field you are accessing is documented as possibly unset:
I think that after this piece of code is executed, it's always set: orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php Lines 1554 to 1573 in 4117ca3
|
@orklah , do you remember why you marked that key as possibly unset? |
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.
PR is good! This makes sense to add
You should update the baseline of psalm with these two errors included as @greg0ire said its done in other places already, we can then independently look into making it an always existing column in our psalm mapping.
You can update the baseline with ./vendor/bin/psalm --set-baseline=psalm-baseline.xml
@@ -16,6 +17,7 @@ | |||
use function sprintf; | |||
use function strpos; | |||
use function strtolower; | |||
use function var_dump; |
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.
I believe this is unused, not sure why phpcs/psalm don't complain
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.
That would be because of this:
Lines 34 to 35 in 760397c
<!-- quite overkill to ignore this, but its necessary since Attributes are not detected yet --> | |
<exclude name="SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse" /> |
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.
Ah forgot about having to add that myself :)
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.
Fixed in #9338
Probably a lack of knowledge of Doctrine. What I can see is a property initialized to empty array and not initialized in constructor. But maybe Doctrine make sure to initialize some properties before anything happens with the property |
That's I think I'll just try removing that |
$class = $this->em->getClassMetadata($this->declaringClasses[$columnName]); | ||
$fieldName = $this->fieldMappings[$columnName]; | ||
$classFieldMapping = $class->fieldMappings[$fieldName]; | ||
$columnSql = $tableAlias . '.' . $classFieldMapping['columnName']; |
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.
@beberlei What we if i add a FieldMapping class with array access in another PR? How much will break? Or is there another better plan to get rid of some of the many arrays?
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.
that is a 3.0 task
Addressed in #9339 |
This does not look like a bugfix. Let's target 2.11.x instead? |
d5e319a
to
7637d29
Compare
…appingBuilder::generateSelectClause()
7637d29
to
f508a4b
Compare
"Use var_dump()" removed, rebased and retarget to 2.11.x. psalm issues should be solved been when 2.10.x is merged up to 2.11.x |
Thanks @kimhemsoe ! |
No description provided.