Seems to me acts_as_list has a bug -- I have data where the row id is a random alphaNumeric, not a simple integer. Using acts_as_list with a scope of a related model id, acts_as_list crashes the app due to a faulty query in MySQL something like this: class LineItem < ActiveRecord::Base belongs_to :order acts_as_list :scope => :order_id end Unknown column ''UXPzIdeIuIFkz6n'' in ''where clause'': UPDATE `line_items` SET position = (position - 1) WHERE (order_id = UXPzIdeIuIFkz6n AND position > 5) I''ve been trying several ways to force substition to generate those needed quotes myself, but so far no luck. Anyone battle & solve this? Thx. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/90d4263bed35117280a5e2af66c86980%40ruby-forum.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
Greg Willits wrote in post #1109539:> Seems to me acts_as_list has a bug -- I have data where the row id is a > random alphaNumeric, not a simple integer. Using acts_as_list with a > scope of a related model id, acts_as_list crashes the app due to a > faulty query in MySQL something like this: > > class LineItem < ActiveRecord::Base > belongs_to :order > acts_as_list :scope => :order_id > end > > Unknown column ''UXPzIdeIuIFkz6n'' in ''where clause'': UPDATE `line_items` > SET position = (position - 1) WHERE (order_id = UXPzIdeIuIFkz6n AND > position > 5) > > I''ve been trying several ways to force substition to generate those > needed quotes myself, but so far no luck. > > Anyone battle & solve this? Thx.For future reference this is one of those times that fighting Rails conventions makes your life more difficult as a Rails developer. Rails wants it simple incrementing integer primary keys. If you can accommodate that wish then life for you as a developer gets simpler. If you want a key that is non-numeric, create a separate column and put a unique constraint on it, but let Rails have its standard simple integer key for use in creating associations. If you really want to fix the problem the I suggest you fork the acts_as_list repository and fix the bug there. My guess is that the author of acts_as_list assumed the Rails conventions and never tested the scenario you''ve presented here. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/b6887584ae6c795286fd8a9f9b14f697%40ruby-forum.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
On Monday, May 20, 2013 2:19:28 PM UTC+1, Ruby-Forum.com User wrote:> > Greg Willits wrote in post #1109539: > > Seems to me acts_as_list has a bug -- I have data where the row id is a > > random alphaNumeric, not a simple integer. Using acts_as_list with a > > scope of a related model id, acts_as_list crashes the app due to a > > faulty query in MySQL something like this: > > > > class LineItem < ActiveRecord::Base > > belongs_to :order > > acts_as_list :scope => :order_id > > end > > > > Unknown column ''UXPzIdeIuIFkz6n'' in ''where clause'': UPDATE `line_items` > > SET position = (position - 1) WHERE (order_id = UXPzIdeIuIFkz6n AND > > position > 5) > > > > I''ve been trying several ways to force substition to generate those > > needed quotes myself, but so far no luck. > > > > Anyone battle & solve this? Thx. > > For future reference this is one of those times that fighting Rails > conventions makes your life more difficult as a Rails developer. Rails > wants it simple incrementing integer primary keys. If you can > accommodate that wish then life for you as a developer gets simpler. If > you want a key that is non-numeric, create a separate column and put a > unique constraint on it, but let Rails have its standard simple integer > key for use in creating associations. > >This feels like it should work though - scope is not necessarily a foreign key column (it could easily be a status column for example (open/closed/etc)), so it should work with string valued columns. Also anything which allows an unquoted, user controllable string into an SQL query is a potential security problem Fred> >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/c4db151e-0b00-46db-a3a7-d4c451abf0e8%40googlegroups.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
Robert Walker wrote in post #1109609:> For future reference this is one of those times that fighting Rails > conventions makes your life more difficult as a Rails developer.I''ve done quite a few apps with non-numeric IDs w/o problems until now. Apparently I never needed to scope a list (?) or the originall DHH one didn''t have this problem maybe?> If you really want to fix the problem the I suggest you fork the > acts_as_list repository and fix the bug there...hmm... https://github.com/swanandp/acts_as_list/pull/69 So, awareness, but no fix yet. Frederick Cheung wrote in post #1109627:> This feels like it should work though - scope is not necessarily a > foreign > key column (it could easily be a status column for example > (open/closed/etc)), so it should work with string valued columns. Also > anything which allows an unquoted, user controllable string into an SQL > query is a potential security problemThat''s what I was thinking. Though my (probably incomplete) efforts to inject some quotes have failed. Anyway, I guess I''ll hack at my local copy and see what I come up with... Thanks to both -- gw -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/7cf3004ae3f9e1656219bb094dba168c%40ruby-forum.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
On Monday, May 20, 2013 11:19:40 PM UTC-4, Ruby-Forum.com User wrote:> > Robert Walker wrote in post #1109609: > > For future reference this is one of those times that fighting Rails > > conventions makes your life more difficult as a Rails developer. > > I''ve done quite a few apps with non-numeric IDs w/o problems until now. > Apparently I never needed to scope a list (?) or the originall DHH one > didn''t have this problem maybe? > > > > If you really want to fix the problem the I suggest you fork the > > acts_as_list repository and fix the bug there... > > hmm... > https://github.com/swanandp/acts_as_list/pull/69 > > So, awareness, but no fix yet. > > > Frederick Cheung wrote in post #1109627: > > This feels like it should work though - scope is not necessarily a > > foreign > > key column (it could easily be a status column for example > > (open/closed/etc)), so it should work with string valued columns. Also > > anything which allows an unquoted, user controllable string into an SQL > > query is a potential security problem > > That''s what I was thinking. Though my (probably incomplete) efforts to > inject some quotes have failed. > > Anyway, I guess I''ll hack at my local copy and see what I come up > with... > > Thanks to both > > -- gw > > -- > Posted via http://www.ruby-forum.com/. >The position column in the mapped table needs to be an integer. See: github.com/rails/acts_as_list -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/3875f1e1-bbfb-4a58-90e6-129deef0ac47%40googlegroups.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
mike wrote in post #1109708:> On Monday, May 20, 2013 11:19:40 PM UTC-4, Ruby-Forum.com User wrote: >> > If you really want to fix the problem the I suggest you fork the >> > foreign >> >> Thanks to both >> >> -- gw >> >> -- >> Posted via http://www.ruby-forum.com/. >> > > The position column in the mapped table needs to be an integer. See: > > github.com/rails/acts_as_listThx, but we''re not talking about the position column. (and that link is to a much older version) -- gw -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8b96797e0b6c5e8f57f37d721d22adec%40ruby-forum.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.
Greg Willits wrote in post #1109539:> Seems to me acts_as_list has a bug -- I have data where the row id is a > random alphaNumeric, not a simple integer. Using acts_as_list with a > scope of a related model id, acts_as_list crashes the app due to a > faulty query in MySQL something like this: > > Unknown column ''UXPzIdeIuIFkz6n'' in ''where clause'': UPDATE `line_items` > SET position = (position - 1) WHERE (order_id = UXPzIdeIuIFkz6n AND > position > 5)Doh!! Gemfile did not have a specified version for acts_as_list and was using an older version. Version 0.2.0 appears to be working fine. With a simple scope, adding/deleting are working as I need them too. -- gw -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/079b1de9022af0dd2bdd5e9290ae5f23%40ruby-forum.com?hl=en-US. For more options, visit https://groups.google.com/groups/opt_out.