On Sunday, April 12, 2015 at 12:08:31 AM UTC-7, Patrick Kuykendall wrote:
>
> Hello,
>
> I'm running into a little issue while using auto_validations plugin on
> varchar columns that have a length of MAX.
>
> This happens to be in MSSQL. It looks like the call for
> CHARACTER_MAXIMUM_LENGTH from INFORMATION_SCHEMA returns a -1 for MAX
> columns in the schema_parse_table method. This is causing the
> auto_validations to reject any values that are greater than -1 in length,
> and if the column is non-nullable it will prevent the record from saving.
>
> Do you know if there a good solution to work around this systemically?
>
You could try this completely untested patch:
diff --git a/lib/sequel/adapters/shared/mssql.rb
b/lib/sequel/adapters/shared/mssql.rb
index 191f0d5..3effec5 100644
--- a/lib/sequel/adapters/shared/mssql.rb
+++ b/lib/sequel/adapters/shared/mssql.rb
@@ -466,7 +466,7 @@ module Sequel
else
schema_column_type(row[:db_type])
end
- row[:max_length] = row[:max_chars] if row[:type] == :string
+ row[:max_length] = row[:max_chars] if row[:type] == :string &&
row[:max_chars] >= 0
[m.call(row.delete(:column)), row]
end
end
Please let me know if that works. If so, I'll make sure it makes it into
the next release.
Thanks,
Jeremy
--
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 http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.