Sha256: 3f64cca7649f13235ddd41c69b8217f798653ad0fa670d24380cb8fff3b2cd12

Contents?: true

Size: 1.1 KB

Versions: 13

Compression:

Stored size: 1.1 KB

Contents

module ActiveRecord
  module ConnectionAdapters
    class SQLServerColumn < Column

      def initialize(name, default, cast_type, sql_type = nil, null = true, sqlserver_options = {})
        super(name, default, cast_type, sql_type, null)
        @sqlserver_options = sqlserver_options.symbolize_keys
        @default_function = @sqlserver_options[:default_function]
      end

      def sql_type_for_statement
        if is_integer? || is_real?
          sql_type.sub(/\((\d+)?\)/, '')
        else
          sql_type
        end
      end

      def table_name
        @sqlserver_options[:table_name]
      end

      def is_identity?
        @sqlserver_options[:is_identity]
      end

      def is_primary?
        @sqlserver_options[:is_primary]
      end

      def is_utf8?
        @sql_type =~ /nvarchar|ntext|nchar/i
      end

      def is_integer?
        @sql_type =~ /int/i
      end

      def is_real?
        @sql_type =~ /real/i
      end

      def collation
        @sqlserver_options[:collation]
      end

      def case_sensitive?
        collation && !collation.match(/_CI/)
      end

    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
activerecord-sqlserver-adapter-4.2.18 lib/active_record/connection_adapters/sqlserver_column.rb
activerecord-sqlserver-adapter-4.2.17 lib/active_record/connection_adapters/sqlserver_column.rb
activerecord-sqlserver-adapter-4.2.16 lib/active_record/connection_adapters/sqlserver_column.rb
activerecord-sqlserver-adapter_new-4.2.15 lib/active_record/connection_adapters/sqlserver_column.rb
activerecord-sqlserver-adapter-4.2.15 lib/active_record/connection_adapters/sqlserver_column.rb
activerecord-sqlserver-adapter-4.2.13 lib/active_record/connection_adapters/sqlserver_column.rb
activerecord-sqlserver-adapter-4.2.12 lib/active_record/connection_adapters/sqlserver_column.rb
activerecord-sqlserver-adapter-4.2.11 lib/active_record/connection_adapters/sqlserver_column.rb
activerecord-sqlserver-adapter-4.2.10 lib/active_record/connection_adapters/sqlserver_column.rb
activerecord-sqlserver-adapter-4.2.9 lib/active_record/connection_adapters/sqlserver_column.rb
activerecord-sqlserver-adapter-4.2.8 lib/active_record/connection_adapters/sqlserver_column.rb
activerecord-sqlserver-adapter-4.2.6 lib/active_record/connection_adapters/sqlserver_column.rb
activerecord-sqlserver-adapter-4.2.5 lib/active_record/connection_adapters/sqlserver_column.rb