Defect #3942

Redmine + PostgreSQL 8.3: ActiveRecord::StatementInvalid in RepositoriesController#revision

Added by Luca Pireddu about 8 years ago. Updated over 7 years ago.

Status:ClosedStart date:2009-09-29
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:SCM
Target version:-
Resolution:Fixed Affected version:

Description

Trying to load a specific revision gives the following error:

PGError: ERROR: operator does not exist: character varying = integer
LINE 1: ...RE ("changesets".repository_id = 20 AND (revision = 33)) OR...
 ^
HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT * FROM "changesets" WHERE ("changesets".repository_id = 20 AND (revision = 33)) ORDER BY changesets.committed_on DESC, changesets.id DESC LIMIT 1

ActiveRecord::StatementInvalid (PGError: ERROR:  operator does not exist: character varying = integer
LINE 1: ...RE ("changesets".repository_id = 20 AND (revision = 33))  OR...
                                                             ^
HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
: SELECT * FROM "changesets" WHERE ("changesets".repository_id = 20 AND (revision = 33))  ORDER BY changesets.committed_on DESC, changesets.id DESC LIMIT 1):
  app/models/repository.rb:97:in `find_changeset_by_name'
  app/controllers/repositories_controller.rb:133:in `revision'
  /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
  /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
  /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
<snip>

This patch seems to fix the problem:

=== modified file 'app/models/repository.rb'
--- app/models/repository.rb    2009-09-20 15:20:22 +0000
+++ app/models/repository.rb    2009-09-29 15:43:37 +0000
@@ -94,7 +94,7 @@

   # Finds and returns a revision with a number or the beginning of a hash
   def find_changeset_by_name(name)
-    changesets.find(:first, :conditions => (name.match(/^\d*$/) ? ["revision = ?", name.to_i] : ["revision LIKE ?", name + '%']))
+    changesets.find(:first, :conditions => (name.match(/^\d*$/) ? ["revision = ?", name] : ["revision LIKE ?", name + '%']))
   end

   def latest_changeset

About
About your application's environment
Ruby version              1.8.7 (i486-linux)
RubyGems version          1.3.5
Rack version              1.0
Rails version             2.3.4
Active Record version     2.3.4
Active Resource version   2.3.4
Action Mailer version     2.3.4
Active Support version    2.3.4
Application root          /home/pireddu/Projects/migrepo/mig_redmine
Environment               development
Database adapter          postgresql
Database schema version   20090704172358

About your Redmine plugins
Redmine Blogs plugin                0.0.6
MIG Redmine Customizations plugin   0.0.1


Related issues

Related to Redmine - Defect #5696: Redmine + PostgreSQL 8.4.4 fails on _dir_list_content.rhtml Closed 2010-06-16
Duplicates Redmine - Defect #3937: Revision view not compatible with all databases Closed 2009-09-28

History

#1 Updated by Jean-Philippe Lang about 8 years ago

  • Status changed from New to Closed
  • Resolution set to Fixed

Fixed in r2903.

#2 Updated by Aurélien Pocheville over 7 years ago

  • Status changed from Closed to Reopened

Hi,

I'm reopening this since I have a very similar problem in
app/views/repositories/_dir_list_content.rhtml

I changed
<% changeset = @project.repository.changesets.find_by_revision(entry.lastrev.identifier) if entry.lastrev && entry.lastrev.identifier %>
to
<% changeset = @project.repository.changesets.find_by_revision(entry.lastrev.identifier.to_s) if entry.lastrev && entry.lastrev.identifier %>

and it worked. Not sure if it applicable everywhere though.

#3 Updated by Felix Schäfer over 7 years ago

  • Status changed from Reopened to Closed

Please open a new defect for this issue, thanks.

Also available in: Atom PDF