-
Notifications
You must be signed in to change notification settings - Fork 2.5k
-
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
DDC-2214: extra single quotation in sql when using EntityRepository::findBy #2911
Comments
Comment created by @FabioBatSilva: Hi Could you please attach your entities or a failing test case ? Cheers |
Comment created by scourgen: sure LineRelated.php :
Line.php
my action:
|
Comment created by @FabioBatSilva: Hi, How did you get this query string ? Repository#findBy does not quote the values, It uses PDO:bindParam.
I tried to reproduce but in my tests the generated Query binds the parameters as "PDO::PARAM_INT". I have added a test case. Cheers |
Comment created by scourgen: reproduced :
let me have a look on what's going on |
Comment created by scourgen: interesting. I've dump(using ladybug_dump) the $lines,and I found out that when the element is a Proxies Object(Object(Proxies__GC__\My\WebBundle\Entity\Line)),then the id of that Object will be with quoted,when the elememt is an Real Entity,then It will be without quote. for example,in my last comment, the parameters is [['6059', 4851, '6068', 126352, '6060', '1000000']] array(6) tell me if you need more information. thanks |
Comment created by @Ocramius: This may be because |
Comment created by scourgen: thanks |
Comment created by @Ocramius: I see what is going on here... But this should not be a problem anyway, since they're bound anyway as "PDO::PARAM_INT", as [~fabio.bat.silva] told you. That's only a problem with the logger showing them as string. PDO will handle the conversion before the value hits the DB as far as I know. |
Comment created by scourgen: I can understand your point,but what I don't really get is that the execute time of sql is very long,that explained the quote should be in the sql,not like what you said,that's only a problem with the logger. |
Comment created by @Ocramius: [~scourgen] can you profile the difference directly in CLI? What about checking the bound parameter type? Are those values bound as INTs in your case? |
Comment created by scourgen: @Ocramius I wish I could, but I was using doctrine2 with symfony2,So It looks like It will takes some time to simulating all environment and settings that could allow me to reproduced the problem. but anyway,I will have a try and tell you what happen when I found something. |
Comment created by @Ocramius: [~scourgen] ok, awaiting your reply then |
Comment created by scourgen: I've spent some time on playing with native doctrine2. It took me awhile to setup everything. but I just don't get that how to retrive data with its Proxy ojbect(for example Proxies_CG_\My\WebBundle\Entity\Line). I mean the result of anyway,I can make sure the problem is real exist,Because the execute time of that slow sql from the tool bar of symfony2 is same as I executed it at mysql cli. If the sql shows up on log with quote but running at mysql without quote,the execute time won't be same(actually It will be much more faster,in my case,20x times,from 2xxms to 10ms). |
Comment created by @Ocramius: [~scourgen] you can use Give it a try :) |
Comment created by scourgen: looks like I reproduced it.
I use MySql Query log to see what's really happen in database(http://dev.mysql.com/doc/refman/5.5/en/query-log.html) this is the log from table mysql.general_log
you can see,in database level,the second parameter of last query but two has quote ( (1, '2', 3) ) |
Comment created by @beberlei: A related Github Pull-Request [GH-247] was opened |
Comment created by @beberlei: A related Github Pull-Request [GH-247] was closed |
Issue was closed with resolution "Fixed" |
Jira issue originally created by user scourgen:
I'm using symfony 2.1 with mysql.
I have following code:
that generate the sql like this:
please notice that the sql has extra single quotation around the number 6059,5677 and 6058. which make the sql very slow.
I did a test, when using single quotation,the sql takes 300ms,when using without single quotation,the sql takes 1 ms.
The text was updated successfully, but these errors were encountered: