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

Runnable query is not runnable in DoctrineDataCollector #24782

Closed
garak opened this issue Nov 1, 2017 · 5 comments
Closed

Runnable query is not runnable in DoctrineDataCollector #24782

garak opened this issue Nov 1, 2017 · 5 comments

Comments

@garak
Copy link
Contributor

garak commented Nov 1, 2017

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.3

This is some kind of re-opening of #20673.
The implementations done in 3b4a8f3 missed the point.
Getting a runnable query like the following one:

SELECT s0_.name AS name_0 FROM slide s0_ WHERE s0_.id = 'Object(Ramsey\\Uuid\\Uuid): \"363dd322-488e-4a60-8caf-c3cfe51f9d7c\"' LIMIT 1;

is pretty useless, because it's obviously not runnable at all.
What I expect is a query like this one:

SELECT s0_.name AS name_0 FROM slide s0_ WHERE s0_.id = '363dd322-488e-4a60-8caf-c3cfe51f9d7c' LIMIT 1;

that is really runnable (e.g. I can copy&paste in some database client)

@xabbuh
Copy link
Member

xabbuh commented Nov 2, 2017

Related to (or duplicate of) #24700?

@garak
Copy link
Contributor Author

garak commented Nov 2, 2017

It's not a duplicate, this case is more general, i.e. it can apply to every time an object is used in a query (not only to an entity used as identifier).

@Simperfit
Copy link
Contributor

Since this has been labeled as a bug, @garak can you work on it ?

@kix
Copy link
Contributor

kix commented Nov 14, 2017

What could be done here is making the DoctrineDataCollector::sanitizeParam return the Object(%s): part commented out so that the output would be like:

SELECT s0_.name AS name_0 FROM slide s0_ WHERE s0_.id = /* Object(Ramsey\\Uuid\\Uuid): */ "363dd322-488e-4a60-8caf-c3cfe51f9d7c" LIMIT 1;

Although I think actually the problem is that parameters are replaced inside the query and not in a separate procedure, e.g. to get a runnable query, we just modify the one we have and fill in the placeholders with values. In my opinion, the runnable query should be a separate entity perhaps.

@fabpot fabpot closed this as completed Dec 7, 2017
fabpot added a commit that referenced this issue Dec 7, 2017
…n runnable part of the query (Simperfit)

This PR was merged into the 4.1-dev branch.

Discussion
----------

[DoctrineBridge] DoctrineDataCollector comments the non runnable part of the query

| Q             | A
| ------------- | ---
| Branch?       | 4.1
| Bug fix?      | yes
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
| Tests pass?   | yes
| Fixed tickets | #24782
| License       | MIT
| Doc PR        | symfony/symfony-docs#... <!--highly recommended for new features-->

![img_2932](https://user-images.githubusercontent.com/3451634/33648180-f6c7a5ac-da58-11e7-8bf8-95fc943d16ff.jpeg)

I think the idea in this ticket is good and it should be implemented. Could we go further by adding more things to this feature, or will it be ok to just comment out the un-needed part to make the kiri
![kiri](https://user-images.githubusercontent.com/3451634/33648278-5eccc830-da59-11e7-8034-a1b9efee7673.png)
(french joke for query) runnable ?

Commits
-------

42760d0 [DoctrineBridge] DoctrineDataCollector comments the non runnable part of the query
@garak
Copy link
Contributor Author

garak commented Oct 1, 2019

Unfortunately, this bug is still present in Symfony 4.4
This is an output example of runnable query:

SELECT u0_.email AS email_0, u0_.password AS password_1, u0_.id AS id_6 FROM user_ u0_ WHERE u0_.id = '/* Object(Ramsey\Uuid\Uuid): */"c91dd2d6-ba8e-11e8-bdaf-0242ac1d0003"' LIMIT 1;

as you can see, the query is not runnable at all, since the whole string (with the comment) is single-quoted, while the double-quoted uuid is escaped 😔

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

No branches or pull requests

7 participants