Package: rails
Version: 2.1.0-6
Severity: normal
Tags: patch

I am somewhat stumped at why this bug has not shown up earlier... But
while converting (and rebuilding the DB on a staging scenario) a Rails
2.0 project to 2.1, I got this strange complaint from PostgreSQL (word
wrapping added by me):

      PGError: ERROR: syntax error at OR near "("
      LINE 1: ...serial PRIMARY KEY, "login" character varying(255)(255) NOT ...
                                                                   ^
      : CREATE TABLE "people" ("id" serial PRIMARY KEY,
                "login" character varying(255)(255) NOT NULL,
                "passwd" character varying(255)(255)(255) NOT NULL,
                "firstname" character varying(255)(255)(255)(255) NOT NULL,
                "famname" character varying(255)(255)(255)(255)(255) NOT NULL,
                "email" character varying(255)(255)(255)(255)(255)(255) DEFAULT 
NULL NULL,
                "pw_salt" character varying(255)(255)(255)(255)(255)(255)(255) 
DEFAULT NULL NULL,
                "created_at" timestamp DEFAULT NULL NULL, "last_login_at" 
timestamp DEFAULT NULL NULL) 

This happens because, in ActiveRecord's SchemaStatements, the field
type corresponding to the :string symbol is modified when adding the
field length - instead of modifying only a copy of it.

The following very simple patch fixes the problem:

diff --git 
a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
 
b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
index 67d70b3..d943e6c 100644
--- 
a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
+++ 
b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -345,7 +345,7 @@ module ActiveRecord
 
       def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc:
         if native = native_database_types[type]
-          column_type_sql = native.is_a?(Hash) ? native[:name] : native
+          column_type_sql = (native.is_a?(Hash) ? native[:name] : native).dup
 
           if type == :decimal # ignore limit, use precision and scale
             scale ||= native[:scale]

Thanks,

-- System Information:
Debian Release: 5.0
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.26-1-vserver-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages rails depends on:
ii  dpkg             1.14.24                 Debian package management system
ii  libbuilder-ruby1 2.1.2-1                 Ruby library to facilitate program
ii  libdbi-ruby1.8   0.2.2-1                 Database Independent Interface for
ii  libjs-prototype  1.6.0.3-1               JavaScript Framework for dynamic w
ii  libpgsql-ruby1.8 0.7.9.2008.03.18-2      PostgreSQL interface for Ruby 1.8
ii  libredcloth-ruby 3.0.99.0.svn.20060519-1 Textile module for Ruby 1.8
ii  libruby [liberb- 4.2                     Libraries necessary to run Ruby 1.
ii  libruby1.8-extra 0.5                     a bundle of additional libraries f
ii  libsqlite3-ruby1 1.2.4-2                 SQLite3 interface for Ruby 1.8
ii  libxml-simple-ru 1.0.11-2                Simple Ruby API for reading and wr
ii  rake             0.8.1-3                 a ruby build program
ii  rdoc             4.2                     Generate documentation from ruby s
ii  ruby             4.2                     An interpreter of object-oriented 
ii  ruby1.8          1.8.7.72-3              Interpreter of object-oriented scr

Versions of packages rails recommends:
ii  irb                           4.2        Interactive Ruby (irb)
ii  libmocha-ruby1.8              0.9.0-1    Mocking and stubbing library for R

Versions of packages rails suggests:
pn  libapache2-mod-ruby | libapac <none>     (no description available)
pn  libfcgi-ruby1.8               <none>     (no description available)

-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to