Forum: Ruby on Rails rails 1.1 and mysql errors

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
M Daggett (Guest)
on 2006-03-23 19:43
(Received via mailing list)
Hi,
I just upgraded to rails 1.1 this morning and i am getting a variety of
errors from tests that were passing effortlessly on the previous edge
release (i froze several weeks ago, so I not sure what version that
was).
Has anyone else experienced these types errors with the new rails:

I have several errors that are grouped around create and destroy
commands
the errors are similar, first the destroy:

test_destroy_comment(ArticleControllerTest):
ActiveRecord::StatementInvalid: Mysql::Error: #42000You have an error in
your SQL syntax; check the manual that corresponds to your
on for the right syntax to use near 'true = true - 1 WHERE (id = 1)' at
line
1: UPDATE articles SET true = true - 1 WHERE (id = 1)

now the error on create:

test_create_child(CategoryControllerTest):
ActiveRecord::StatementInvalid: Mysql::Error: #42000You have an error in
your SQL syntax; check the manual that corresponds to your MySQL server
versi
on for the right syntax to use near 'true = true + 1 WHERE (id = 1)' at
line
1: UPDATE categories SET true = true + 1 WHERE (id = 1)

It appears that the incrementing "1's" are being read as boolean
statements
by mysql. All of this mysql is generated by rails so I have no idea
where to
even start poking around to figure out why it is blowing up.

I am using MYSQL
version 5.0.11 on Windows XP


I am also getting errors on my references using the new "through" option
in
my models. These through methods are almost verbatim from the ones
described
in the rails recipe book so I have no idea what to change. I have a user
who
has many roles though memberships in which they belong; for example:


class User < ActiveRecord::Base
    has_many :memberships
    has_many :roles    , :through=> :memberships
.............

class Membership < ActiveRecord::Base
    belongs_to :user
    has_and_belongs_to_many :roles
............


class Role < ActiveRecord::Base
    has_and_belongs_to_many :memberships
.............

test_reference_roles_through_membership(UserTest):
ActiveRecord::ActiveRecordError: Invalid source reflection macro
:has_and_belongs_to_many for has_many roles, :through => memberships
    c:/ruby/lib/ruby/gems/1.8/gems/activerecord-1.13.2.4008/lib/active_record/associations/has_many_through_association.rb:75:in
`construct_conditions
'


Rails 1.1 does not fix the existing "shim" error with mysql
`destroy_without_habtm_shim_for_[xxMODELxx]'
The ticket with patch is here and it has worked well for me for several
months:

http://dev.rubyonrails.org/ticket/3175


I am very happy to see Rails moving on to bigger and better things, as
soon
as I figure out how to solve these issues I hope to join the rest of you
guys as well!


Anyone with insights on these issues?
Mark
Dag Nabbit (Guest)
on 2006-03-23 20:04
M Daggett wrote:
>
> Rails 1.1 does not fix the existing "shim" error with mysql
> `destroy_without_habtm_shim_for_[xxMODELxx]'
> The ticket with patch is here and it has worked well for me for several
> months:
>
> http://dev.rubyonrails.org/ticket/3175
>

I don't see any patch in ticket #3175.  And it was closed with a
'worksforme'...

If the patch fixes a problem with Rails 1.1-RC1, please create a new
ticket unless you find an existing ticket.

Good luck!
M Daggett (Guest)
on 2006-03-23 21:00
(Received via mailing list)
Hi,
I guess I should not have used the word "patch" because it was not a
external file that overwrote the exisiting class. Instead the only way
to
get this to work is to modify the associations.rb file directly.  I did
try
to make a patch file at one time but was never able to correctly
reference
the correct portion of the base code.

I still do see previously documented error in the current relase
canidate.


The bug appears at line 668 of associations.rb and is fixed by adding an
unless clause before the class eval like so:


unless method_defined?(old_method) # !!! added for the HABTM_SHIM DELETE
bug
  class_eval <<-end_eval
    alias_method :#{old_method}, :destroy_without_callbacks
    def destroy_without_callbacks
      #{reflection.name}.clear
      #{old_method}
    end
   end_eval
 end #!!! eof HABTM_SHIM DELETE bug fix
This topic is locked and can not be replied to.