On Monday, March 14, 2016 at 4:15:35 PM UTC+1, Jeremy Evans wrote:
>
> On Monday, March 14, 2016 at 7:45:04 AM UTC-7, Ilja Resch wrote:
>>
>> Hi,
>>
>> At the moment it is not possible to alter column with 
>> set_column_allow_null,
>>
>> when column-type is text, ntext, nvarchar(MAX) or varchar(MAX).
>>
>> Following sql is created.
>>
>> In case of (n)text:
>> ALTER TABLE [test_migration] ALTER COLUMN [text_column] text(2147483647) 
>> NULL
>> ALTER TABLE [test_migration] ALTER COLUMN [ntext_column] ntext(1073741823
>> ) NULL
>>
>>
>> and in case of (n)varchar(MAX):
>> ALTER TABLE [test_migration] ALTER COLUMN [nvarcharmax_column] nvarchar(-
>> 1) NULL
>> ALTER TABLE [test_migration] ALTER COLUMN [varcharmax_column] varchar(-1) 
>> NULL
>>
>> This would fix the Problem:
>> lib/sequel/adapters/shared/mssql.rb:284 (alter_table_sql(table, op))
>> sch = schema(table).find{|k,v| k.to_s == op[:name].to_s}.last
>> type = sch[:db_type]
>> if [:string, :decimal].include?(sch[:type]) && !["text", 
>> "ntext"].include?(type) and size = (sch[:max_chars] || sch[:column_size])
>>   size = "MAX" if size == -1
>>   type += "(#{size}#{", #{sch[:scale]}" if sch[:scale] && 
>> sch[:scale].to_i > 0})"
>> end
>>
>> I did not found any other methods with this issue. But I'm not sure if 
>> this is the best way to fix it.
>>
>> Thanks
>>
>
> This appears to be a good fix.  In any case, it shouldn't hurt as -1 
> shouldn't be a valid size. I'm running it through the test suites now, if 
> it passes I'll push it up to GitHub.
>
> Thanks,
> Jeremy
>

Hi,

Glad to contribute. But there is still the problem with *text* and *next. *
ALTER TABLE [test_migration] ALTER COLUMN [text_column] text(2147483647) 
NULL
ALTER TABLE [test_migration] ALTER COLUMN [ntext_column] ntext(1073741823) 
NULL

The column size is wrong.
*Text* and *ntext* columns should not have any size behind the column type. 
Possible fix would be the addition of:
!["text", "ntext"].include?(type)
in
if [:string, :decimal].include?(sch[:type]) and !["text", "ntext"].include?(
type) and size = (sch[:max_chars] || sch[:column_size])

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to