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

Discriminator value could be an integer #11425

Merged
merged 1 commit into from
May 15, 2024

Conversation

prohalexey
Copy link
Contributor

@prohalexey prohalexey commented Apr 25, 2024

The same as

399:    $values[] = $conn->quote((string) $subclassMetadata->discriminatorValue);

Without casting a TypeError is raised.

@greg0ire
Copy link
Member

The change on line 399 was introduced in a merge up: 5a40b99 🤔

@greg0ire greg0ire requested a review from derrabus April 28, 2024 15:10
@greg0ire greg0ire added the Bug label Apr 28, 2024
greg0ire
greg0ire previously approved these changes Apr 28, 2024
SenseException
SenseException previously approved these changes Apr 28, 2024
@W0rma
Copy link
Contributor

W0rma commented Apr 29, 2024

@prohalexey Does this PR fix #11341?

Does it make sense to add the unit tests which are suggested in this issue?

@greg0ire
Copy link
Member

Does it make sense to add the unit tests which are suggested in this issue?

Yes, please do 🙏

@prohalexey
Copy link
Contributor Author

Any news here @greg0ire @W0rma ?

@greg0ire
Copy link
Member

greg0ire commented May 7, 2024

@prohalexey can you please incorporate the unit tests suggested in #11341 ?

@prohalexey prohalexey dismissed stale reviews from SenseException and greg0ire via 0097839 May 7, 2024 13:48
@prohalexey
Copy link
Contributor Author

Tests have been added and the code has been changed to a more accurate version. @greg0ire pls, look

@prohalexey
Copy link
Contributor Author

@greg0ire @SenseException @derrabus could someone check this pr ?

@greg0ire
Copy link
Member

Please kindly squash your commits together. If you don't, we'll try to remember to do it for you but it's best if you save us this trouble.

How to do that?

  1. git rebase -i origin/3.1.x, assuming origin is a git remote that points to this repository, and not your fork. If you're not sure what your remotes are, run git remote -vvv, there should be your fork and the holy/reference/base/origin/whatever-you-call-it repository.
  2. A window will show up with many lines, replace pick with fixup on every line but the first one
  3. Close your editor, git should do its magic, and you should end up with one commit
  4. Use git push --force to overwrite what you already push. Don't forget the --force option otherwise git will try to merge both things together.

Also, once you have a single commit, please improve your commit message according to the contributing guide. "Discriminator value could be an integer (TypeError is raised)" is not enough IMO.

This fixes a bug that occurred when configuring integers as discriminator values. Doctrine throws a type error whenever the application generates queries.
@prohalexey prohalexey force-pushed the FixForIntegerDescriminatorValue branch from 381e605 to e83d8a8 Compare May 15, 2024 07:42
@prohalexey
Copy link
Contributor Author

@greg0ire I think I'm done.

@greg0ire greg0ire added this to the 3.1.4 milestone May 15, 2024
@greg0ire greg0ire merged commit 3d9af31 into doctrine:3.1.x May 15, 2024
62 checks passed
@greg0ire
Copy link
Member

Thanks @prohalexey !

@yakijavier
Copy link

Hello @greg0ire , if it is supposed to be possible to use an integer as a descriminator, in the SqlWalker.php file in line 2255 shouldn't the discriminator be cast to string so that quote() accepts it?

@greg0ire
Copy link
Member

I think so yeah… my IDE prints a warning, but I'm not sure why static analysis does not report it. @prohalexey what do you think?

@prohalexey
Copy link
Contributor Author

prohalexey commented May 15, 2024

I ran tests(GH11341Test, GH11199Test) and did not stop at this line (I set breakpoint at 2255). Trying to understand what conditions we must have to call this function getChildDiscriminatorsFromClassMetadata

@prohalexey
Copy link
Contributor Author

Yep, I confirm that there is a bug if you make DQL query with INSTANCEOF function. I will create a new PR. @greg0ire

@prohalexey
Copy link
Contributor Author

New PR #11456

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants