Sha256: 391b7e987b460fdcfc6a2f62e830e3da30c52e7e45facb3fe37f67943e3a56f9

Contents?: true

Size: 923 Bytes

Versions: 8

Compression:

Stored size: 923 Bytes

Contents

module ActiveRecord
  module ConnectionAdapters
    module MSSQL
      class SchemaCreation < AbstractAdapter::SchemaCreation
        private

        def visit_TableDefinition(o)
          if o.as
            table_name = quote_table_name(o.temporary ? "##{o.name}" : o.name)
            projections, source = @conn.to_sql(o.as).match(%r{SELECT\s+(.*)?\s+FROM\s+(.*)?}).captures
            select_into = "SELECT #{projections} INTO #{table_name} FROM #{source}"
          else
            o.instance_variable_set :@as, nil
            super
          end
        end

        # There is no RESTRICT in MSSQL but it has NO ACTION which behave
        # same as RESTRICT, added this behave according rails api.
        def action_sql(action, dependency)
          case dependency
          when :restrict then "ON #{action} NO ACTION"
          else
            super
          end
        end

      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
activerecord-jdbc-alt-adapter-50.7.0-java lib/arjdbc/mssql/schema_creation.rb
activerecord-jdbc-alt-adapter-50.6.1-java lib/arjdbc/mssql/schema_creation.rb
activerecord-jdbc-alt-adapter-50.5.0-java lib/arjdbc/mssql/schema_creation.rb
activerecord-jdbc-alt-adapter-50.3.4-java lib/arjdbc/mssql/schema_creation.rb
activerecord-jdbc-alt-adapter-50.3.3-java lib/arjdbc/mssql/schema_creation.rb
activerecord-jdbc-alt-adapter-50.3.2-java lib/arjdbc/mssql/schema_creation.rb
activerecord-jdbc-alt-adapter-50.3.1-java lib/arjdbc/mssql/schema_creation.rb
activerecord-jdbc-alt-adapter-50.3.0-java lib/arjdbc/mssql/schema_creation.rb