Geoff Coffey
2007-Sep-22 17:11 UTC
Noob wants feedback on #4905: MySQL Tables with lousy names
I''m trying to use AR to work with a legacy database, over which I have no control. This database has two problematic table names: ''group'' and ''order''. Of course in mysql itself this is really no problem, but AR fails to properly quote the table name in a lot of places. Whether or not it''s a "good idea" to have table names like this, some of us are stuck with them. I''ve just posted a patch to #4905 to fix this problem comprehensively for MySQL (and the infrastructure to easily fix it for any other database that allows table names like this). The biggest problem, from my point of view, is that you can''t use fixtures with a database like this. You also can''t dump schema from MySQL in this case, and you have to use a questionable workaround in model classes to get any of AR to work at all. This very much seems to me like something AR should handle more elegantly, since it isn''t particularly hard to do. This is my first patch, and the first time I''ve peeked under the hood of AR, so I''m sure there are places it needs improvement. The patch includes several test cases, all of which fail on the trunk and pass with the patch in place. The full MySQL test suite also passes, but *I have not run tests on other databases*. Thanks, and please feel free to beat me up on this. I''m learning about the rails contribution process here. Geoff --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Geoff Coffey
2007-Sep-22 18:19 UTC
Re: Noob wants feedback on #4905: MySQL Tables with lousy names
> I''ve just posted a patch to #4905 to fix this problem comprehensivelySorry for the spam. I should have mentioned in the previous email that there are *two* patches on that ticket. The first is old, and was posted by someone else. It doesn''t actually fix the problem comprehensively. The second is my patch, which I believe fixes things properly. The first patch should be ignored. Thanks! Geoff --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Mislav Marohnić
2007-Sep-22 18:40 UTC
Re: Noob wants feedback on #4905: MySQL Tables with lousy names
On 9/22/07, Geoff Coffey <gwcoffey@gmail.com> wrote:> > > Sorry for the spam. I should have mentioned in the previous email that > there are *two* patches on that ticket. The first is old, and was > posted by someone else. It doesn''t actually fix the problem > comprehensively.We can read, Geoff :P Your patch broke MySQL 5 heavily for me. I''ve uploaded my test results, since it is not clear to me from the first glance what exactly broke those (unrelated) tests. I''m sure you will fix it faster than I could. The one thing I noticed immediately from the SQL errors is that there are many more SQL queries with unquoted tables names. Postgres and Sqlite3 suites pass without failures. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Geoff Coffey
2007-Sep-22 19:31 UTC
Re: Noob wants feedback on #4905: MySQL Tables with lousy names
> Your patch broke MySQL 5 heavily for me. I''ve uploaded my test results, > since it is not clear to me from the first glance what exactly broke those > (unrelated) tests. I''m sure you will fix it faster than I could.Mislav: Thanks for the quick response. I got the same errors as you once when I stopped the test mid-stream. I fixed it by dropping and re-creating my activerecord_unittest and activerecord_unittest2 tables. The errors are in tests I did not modify and they occur because one of the test cases creates the tables but they already exist. It is possible I broke something. Is it supposed to gracefully deal with this situation? I think you''ll find that if you drop and re-add your databases, the tests run without error. Also, I just discovered that there are three duplicates of this ticket, and one of them already has a patch in place (4593). I think my patch is more comprehensive (it fixes Fixtures, which the other doesn''t). I''ll look at combining them. Finally, I see there were some queries I missed. I''ll clean those up too. Thanks so much, Geoff --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---
Gabe da Silveira
2007-Sep-22 20:41 UTC
Re: Noob wants feedback on #4905: MySQL Tables with lousy names
On 9/22/07, Geoff Coffey <gwcoffey@gmail.com> wrote:> > > > Your patch broke MySQL 5 heavily for me. I''ve uploaded my test results, > > since it is not clear to me from the first glance what exactly broke > those > > (unrelated) tests. I''m sure you will fix it faster than I could. > > Mislav: > > Thanks for the quick response. I got the same errors as you once when > I stopped the test mid-stream. I fixed it by dropping and re-creating > my activerecord_unittest and activerecord_unittest2 tables. The errors > are in tests I did not modify and they occur because one of the test > cases creates the tables but they already exist. It is possible I > broke something. Is it supposed to gracefully deal with this > situation? >Same thing happened for me, but also when I cancelled the test run in the middle (Ctrl-C) the problem re-appeared. Why is the database left in an unconsistent state? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com To unsubscribe from this group, send email to rubyonrails-core-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en -~----------~----~----~----~------~----~------~--~---