Hyperdimensional strings
I am stunned no more people have been bitten by this. Or at least, the Intarweb has not heard about it. Censorship perhaps? I haven't researched more into the causes, but anyway...
I was pushing a project I have had lingering for some time from Rails 2.0.x to 2.1.x (yes, 2.2 is already out there, but 2.1 is the version that will ship with Lenny) - The changes should not be too invasive, as it is a minor release, but there are some quite noticeable changes.
Anyway... What was the problem? Take this very simple migration:
class CreatePeople < ActiveRecord::Migration def self.up create_table :people do |t| t.column :login, :string, :null => false t.column :passwd, :string, :null => false t.column :firstname, :string, :null => false t.column :famname, :string, :null => false t.column :email, :string t.column :pw_salt, :string t.column :created_at, :timestamp t.column :last_login_at, :timestamp end end def self.down drop_table :people end end
The problem is that PostgreSQL refuses to create a hyperdimensional string field. I offer this here to you, line-wrapped by me for your convenience.
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)
Beautiful. Now I can store strings not only as character vectors, but as planes, cubes, hypercubes, and any other hyperdimensional construct! Are we approaching quantum computers?
What is really striking is that... I found only one occurrence on tha net of this bug - one and a half years ago, in Ola Bini's blog. No stunned users looking for the culprit, no further reports... Strange.
Still, the bug was fixed in Rails 2.2 about half a year ago, although not in revisions of earlier versions. I will request the patch to be applied to earlier versions as well. Sigh.
- Bitácora de gwolf
- Log in or register to post comments