class CreateComputers < ActiveRecord::Migration
def self.up
create_table :computers do |t|
t.string :name
t.string :state
t.string :company
t.string :serial_number
t.string :type
t.string :model
t.string :operating_system
t.string :cpu
t.integer :cpu_mhz
t.integer :ram
t.string :position
t.string :contact
t.string :contact_tel
t.string :ath_code
t.datetime :last_modified
t.text :notes
t.timestamps
end
end
I've done some features and scenarios for cucumber.
When I run rake:cucumber I have this error:
rake aborted!
ActiveRecord::JDBCError: ERROR: type modifier is not allowed for type "text"
Posizione: 418: CREATE TABLE "computers" ("id" serial primary key,
"name" varchar(255), "state" varchar(255), "company" varchar(255),
"serial_number" varchar(255), "type" varchar(255), "model"
varchar(255), "operating_system" varchar(255), "cpu" varchar(255),
"cpu_mhz" bigint, "ram" bigint, "position" varchar(255), "contact"
varchar(255), "contact_tel" varchar(255), "ath_code" varchar(255),
"last_modified" timestamp(29), "notes" text(2147483647), "created_at"
timestamp(29), "updated_at" timestamp(29))
If I modify notes in string rather than text cucumber works.
Why I have that jdbc error?
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
your error seams different that what I saw but the underlying reason
might be the same.
regards, Kristian
Renaming the table field?
I've do that renaming notes in comments but it doesn't helped, the
error is still:
rake aborted!
ActiveRecord::JDBCError: ERROR: type modifier is not allowed for type "text"
Posizione: 421: CREATE TABLE "computers" ("id" serial primary key,
"name" varchar(255), "state" varchar(255), "company" varchar(255),
"serial_number" varchar(255), "type" varchar(255), "model"
varchar(255), "operating_system" varchar(255), "cpu" varchar(255),
"cpu_mhz" bigint, "ram" bigint, "position" varchar(255), "contact"
varchar(255), "contact_tel" varchar(255), "ath_code" varchar(255),
"last_modified" timestamp(29), "comments" text(2147483647),
"created_at" timestamp(29), "updated_at" timestamp(29))
---------------------------------------------------------------------
so if you can execute the following query
CREATE TABLE "computers" ("id" serial primary key,
"name" varchar(255), "state" varchar(255), "company" varchar(255),
"serial_number" varchar(255), "type" varchar(255), "model"
varchar(255), "operating_system" varchar(255), "cpu" varchar(255),
"cpu_mhz" bigint, "ram" bigint, "position" varchar(255), "contact"
varchar(255), "contact_tel" varchar(255), "ath_code" varchar(255),
"last_modified" timestamp(29), "comments" text,
"created_at" timestamp(29), "updated_at" timestamp(29))
without length in text than you found a bug. which database are you using ?
is the actual task which fails the cucumber tasks or db:migrate from rails ?
regards, Kristian
I'm using postgres.
> is the actual task which fails the cucumber tasks or db:migrate from rails ?
>
db:migrate is ok, in all my rails applications I have no problems with
fields of type text.
It is the cucumber task that fails.
I ran into a similar problem when running "rake spec". I am using JRuby,
Rails 3, and activerecord-jdbcpostgresql-adapter 1.0.2. The problem
seems to be that when running db:migrate the db:schema:dump task is
creating a db/schema.rb file that specifies a :limit for "text" column
types and PostgreSQL does not allow specifying such a limit. I think
what needs to be fixed is the dump task for PostgreSQL databases and
possibly only when using the JDBC driver (I haven't tested using
anything
other than JRuby so I don't know if this problem exists when using MRI
and the native PostgreSQL driver).
I don't have time to look into a fix for this right now and simply
modified my schema.rb file in order to get my tests to work. There may
be similar problems with timestamps as well. The schema.rb specifies a
limit of 29 for timestamps but when I run the SQL generated by the
db:schema:load task directly on the PostgreSQL console, Postgres gives a
warning that the maximum precision of 6 will be used for the timestamps.
I have just gotten into Rails, and JRuby especially, so I don't know if
I
can fix this problem at the appropriate level, but I will attempt to
take a look at it when I get a chance.
--
Posted via http://www.ruby-forum.com/.
I must only delete the :limit specification for text types?
That's all I did for now. The issue with the timestamps just gives a
warning but should probably be fixed whenever the underlying issue with
text types is fixed. Note however, that you will need to edit the
schema.rb file each time you run db:migrate because it gets regenerated.
--
Posted via http://www.ruby-forum.com/.
---------------------------------------------------------------------
I hit is when trying to do rake db:test:prepare, and removing the limit
from the text fields does indeed solve the problem. It seems to be an
issue with migrate, which generates the schema.rb file a fresh each time
with this erroneous limit. I am sure earlier versions of Rails did not
(pretty sure this was not a problem in 2.3.8), but 2.3.9 does (would not
care to say about the ones in between).
I would guess this is an issue in schema_dumper or
connection_adapters/postgresql_adapter.rb in active_record, but they
appear to be unchanged between 2.3.8 and 2.3.9.
A fix (not necessarily the best, and only slightly tested) is to modify
jruby-1.5.2\lib\ruby\gems\1.8\gems\activerecord-2.3.9\lib\active_record/schema_dumb.rb,
line 107
From:
spec[:limit] = column.limit.inspect if column.limit !=
@types[column.type][:limit] && column.type != :decimal
To:
spec[:limit] = column.limit.inspect if column.limit !=
@types[column.type][:limit] && ![:decimal, :text].include?(column.type)
--
Posted via http://www.ruby-forum.com/.
---------------------------------------------------------------------
spec[:limit] = column.limit.inspect if column.limit !=
@types[column.type][:limit] && ![:decimal, :text,
:date].include?(column.type)
--
Posted via http://www.ruby-forum.com/.
---------------------------------------------------------------------