Wrong interpretation of limit in both Mysql and PostgreSQL adapters

Can anyone check this ticket? http://dev.rubyonrails.org/ticket/5489

It's 1 year old already, but still valid imho.

Can anyone check this ticket? http://dev.rubyonrails.org/ticket/5489

It's 1 year old already, but still valid imho.

I don't quite follow what the problem is with the current implementation? could you give me an example of what bugs / mis-behaviour this patch will prevent?

Sure.

Well, I was asked to include #5484 into this ticket, so it is dealing with distinct bugs at once.

To understand those bugs, let's begin with a single migration that creates a table with one column:     t.column :limit3, :integer, :limit => 3

1) When you run this migration under postgresql, the column is dumped to schema.rb without the limit:     t.column "limit3", :integer

The patch in this ticket fixes the postgresql adapter to dump columns with limits.

2) Also in postgresql, the above migration will generate a smallint column, which uses 2 bytes for storage. I think it should generate an integer column, so it can handle 3 bytes numbers without overflow -- and this is also covered by the patch attached.

3) Finally, in mysql the migration will generate a INT(3) column, what means a column with display size of 3, and not a column with 3 bytes for storage. The patch changes mysql adapter to use the limit constraint to generate smallint, mediumint, int and bigint columns accordingly.

Well, I was asked to include #5484 into this ticket, so it is dealing with distinct bugs at once.

Sounds good. This patch breaks sqlite's tests, if you can merge those in, it seems good to apply.

ops, I'm back.

well, sqlite doesn't support :limit anyways, so I guess we should skip this test for adapters that doesn't support it, correct?

any ideas?

humm just reminded about this

tarmo added sqlite tests. can anyone check and hopefully add?

gee, no more sql files for creating test database structures? i'll try to update the patch once again

ok, patch updated against r8279 can anyone verify?