This patch is an update for Rails 1.1 to these changes that force lowercase the column names in MS SQL databases: Patch with:
patchfile contents:patch /usr/lib/ruby/gems/1.8/gems/activerecord-1.14.0/lib/active_record/connection_adapters/sqlserver_adapter.rb
246c246
< sql = "SELECT LOWER(COLUMN_NAME) as colname, COLUMN_DEFAULT as defaultvalue, DATA_TYPE as coltype, IS_NULLABLE As isnullable, COL_LENGTH('#{table_name}', COLUMN_NAME) as length, COLUMNPROPERTY(OBJECT_ID('#{table_name}'), COLUMN_NAME, 'IsIdentity') as isidentity, NUMERIC_SCALE as scale FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '#{table_name}'"> sql = "SELECT COLUMN_NAME as ColName, COLUMN_DEFAULT as DefaultValue, DATA_TYPE as ColType, IS_NULLABLE As IsNullable, COL_LENGTH('#{table_name}', COLUMN_NAME) as Length, COLUMNPROPERTY(OBJECT_ID('#{table_name}'), COLUMN_NAME, 'IsIdentity') as IsIdentity, NUMERIC_SCALE as Scale FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '#{table_name}'"
254,258c254,258
< default =" field[:defaultvalue].to_s.gsub!(/[()\']/," type = "#{field[:coltype]}(#{field[:length]})" is_identity =" field[:isidentity]" is_nullable =" field[:isnullable]"> default = field[:DefaultValue].to_s.gsub!(/[()\']/,"") =~ /null/ ? nil : field[:DefaultValue]
> type = "#{field[:ColType]}(#{field[:Length]})"
> is_identity = field[:IsIdentity] == 1
> is_nullable = field[:IsNullable] == 'YES'
> columns <<> id_value || select_one("SELECT @@IDENTITY AS Ident")["Ident"]
300c300
< retval =" select_one("> retVal = select_one("SELECT @@ROWCOUNT AS AffectedRows")["AffectedRows"]
366c366
< total_rows =" @connection.select_all("> total_rows = @connection.select_all("SELECT count(*) as TotalRows from (#{sql.gsub(/\bSELECT\b/i, "SELECT TOP 1000000000")}) tally")[0][:TotalRows].to_i
489,490c489,490
<> record[col] = row[col]
> record[col] = record[col].to_time if record[col].is_a? DBI::Timestamp
0 comments:
Post a Comment