Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #4084 (new defect)

Opened 2 years ago

Last modified 9 months ago

[PATCH] act_as_list fails if using string for primary key

Reported by: anonymous Assigned to: David
Priority: normal Milestone: 2.x
Component: Plugins Version: edge
Severity: normal Keywords:
Cc: tolsen@limewire.com, kmag@alum.mit.edu, jschmidt@alum.mit.edu

Description

act_as_list fails if using guid string for primary key

the id field is not quoted in the sql query causing the query to fail

Attachments

4084_quote_scope_condition_value.diff (1.5 kB) - added by Caio Chassot <caio@v2studio.com> on 07/22/06 18:26:18.
6549_quote_scope_condition_value.diff (1.6 kB) - added by josh on 04/22/07 17:34:25.

Change History

03/22/06 22:38:07 changed by anonymous

  • cc set to tolsen@limewire.com, kmagdsick@limewire.com, jschmidt@limewire.com.

03/22/06 22:40:43 changed by justin@limewire.com

Specifically, the problem seems to be based on the definition of the scope_condition method around line 46.

03/22/06 22:41:02 changed by anonymous

  • cc changed from tolsen@limewire.com, kmagdsick@limewire.com, jschmidt@limewire.com to tolsen@limewire.com, kmagdsick@limewire.com, justin@limewire.com.

03/22/06 22:43:51 changed by justin@limewire.com

  • severity changed from normal to major.
  • summary changed from act_as_list fails if using guid for primary key to act_as_list fails if using string for primary key.

03/22/06 23:18:21 changed by justin@limewire.com

Not that this is a great fix, but the following workaround enabled me to move forward. Be wary of weird characters such as quotes in the value!

Replace line 46 of lib/active_record/acts/list.rb with the following:

                  value = "\#{#{configuration[:scope].to_s}}"
                  if value.kind_of? String
                    "#{configuration[:scope].to_s} = '" + value + "'"
                  else
                    "#{configuration[:scope].to_s} = " + value
                  end

04/06/06 01:35:56 changed by anonymous

Does the problem exist for rails 1.1.0 or the latest revision? If so, can you submit your workaround as a patch file so it can get incorporated into rails?

Thanks.

07/22/06 18:26:07 changed by Caio Chassot <caio@v2studio.com>

  • priority changed from high to normal.
  • version changed from 1.0.0 to 1.1.1.
  • severity changed from major to normal.
  • summary changed from act_as_list fails if using string for primary key to [PATCH] act_as_list fails if using string for primary key.

Confirmed with current trunk. Patch is coming.

07/22/06 18:26:18 changed by Caio Chassot <caio@v2studio.com>

  • attachment 4084_quote_scope_condition_value.diff added.

04/22/07 17:34:25 changed by josh

  • attachment 6549_quote_scope_condition_value.diff added.

04/22/07 17:35:19 changed by josh

  • keywords set to unverified.
  • version changed from 1.1.1 to edge.
  • milestone set to 1.x.

Could use some tests and other people testing out the patch.

04/23/07 15:06:33 changed by tolsen

  • cc changed from tolsen@limewire.com, kmagdsick@limewire.com, justin@limewire.com to tolsen@limewire.com, kmag@alum.mit.edu, justin@alum.mit.edu.

04/23/07 15:06:51 changed by tolsen

  • cc changed from tolsen@limewire.com, kmag@alum.mit.edu, justin@alum.mit.edu to tolsen@limewire.com, kmag@alum.mit.edu, jschmidt@alum.mit.edu.

07/19/07 23:29:59 changed by lifofifo

  • keywords deleted.

10/08/07 04:12:57 changed by tarmo

  • component changed from ActiveRecord to Plugins.