Sha256: c1759724fea775b7ce4b74f610ab91a0ef74c128163f4d96d84229c0ef42aafe

Contents?: true

Size: 1.92 KB

Versions: 21

Compression:

Stored size: 1.92 KB

Contents

require 'cases/helper_sqlserver'

class SchemaTestSQLServer < ActiveRecord::TestCase

  describe 'When table is dbo schema' do

    it 'find primary key for tables with odd schema' do
      connection.primary_key('sst_natural_pk_data').must_equal 'legacy_id'
    end

  end

  describe 'When table is in non-dbo schema' do

    it 'work with table exists' do
      assert connection.data_source_exists?('test.sst_schema_natural_id')
      assert connection.data_source_exists?('[test].[sst_schema_natural_id]')
    end

    it 'find primary key for tables with odd schema' do
      connection.primary_key('test.sst_schema_natural_id').must_equal 'legacy_id'
    end

    it "have only one identity column" do
      columns = connection.columns("test.sst_schema_identity")
      assert_equal 2, columns.size
      assert_equal 1, columns.select{ |c| c.is_identity? }.size
    end

    it "read only column properties for table in specific schema" do
      test_columns = connection.columns("test.sst_schema_columns")
      dbo_columns = connection.columns("dbo.sst_schema_columns")
      columns = connection.columns("sst_schema_columns") # This returns table from dbo schema
      assert_equal 7, test_columns.size
      assert_equal 2, dbo_columns.size
      assert_equal 2, columns.size
      assert_equal 1, test_columns.select{ |c| c.is_identity? }.size
      assert_equal 1, dbo_columns.select{ |c| c.is_identity? }.size
      assert_equal 1, columns.select{ |c| c.is_identity? }.size
    end

    it "return correct varchar and nvarchar column limit length when table is in non dbo schema" do
      columns = connection.columns("test.sst_schema_columns")
      assert_equal 255, columns.find {|c| c.name == 'name'}.limit
      assert_equal 1000, columns.find {|c| c.name == 'description'}.limit
      assert_equal 255, columns.find {|c| c.name == 'n_name'}.limit
      assert_equal 1000, columns.find {|c| c.name == 'n_description'}.limit
    end

  end


end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
activerecord-jdbcsqlserver-adapter-51.1.0 test/cases/schema_test_sqlserver.rb
activerecord-jdbcsqlserver-adapter-50.1.0 test/cases/schema_test_sqlserver.rb
activerecord-jdbcsqlserver-adapter-51.0.1 test/cases/schema_test_sqlserver.rb
activerecord-jdbcsqlserver-adapter-51.0.0 test/cases/schema_test_sqlserver.rb
activerecord-jdbcsqlserver-adapter-50.0.0 test/cases/schema_test_sqlserver.rb
activerecord-sqlserver-adapter-5.2.0 test/cases/schema_test_sqlserver.rb
activerecord-sqlserver-adapter-5.2.0.rc2 test/cases/schema_test_sqlserver.rb
activerecord-sqlserver-adapter-5.2.0.rc1 test/cases/schema_test_sqlserver.rb
activerecord-sqlserver-adapter-5.1.6 test/cases/schema_test_sqlserver.rb
activerecord-sqlserver-adapter-5.0.8 test/cases/schema_test_sqlserver.rb
activerecord-sqlserver-adapter-5.1.5 test/cases/schema_test_sqlserver.rb
activerecord-sqlserver-adapter-5.1.2 test/cases/schema_test_sqlserver.rb
activerecord-sqlserver-adapter-5.1.1 test/cases/schema_test_sqlserver.rb
activerecord-sqlserver-adapter-5.1.0 test/cases/schema_test_sqlserver.rb
activerecord-sqlserver-adapter-5.0.7 test/cases/schema_test_sqlserver.rb
activerecord-sqlserver-adapter-5.0.6 test/cases/schema_test_sqlserver.rb
activerecord-sqlserver-adapter-5.0.5 test/cases/schema_test_sqlserver.rb
activerecord-sqlserver-adapter-5.0.4 test/cases/schema_test_sqlserver.rb
activerecord-sqlserver-adapter-5.0.3 test/cases/schema_test_sqlserver.rb
activerecord-sqlserver-adapter-5.0.1 test/cases/schema_test_sqlserver.rb