Esempio n. 1
0
        private void HandleTransitiveRenames()
        {
            const string temporaryNamePrefix = "__mig_tmp__";
            var          temporaryNameIndex  = 0;

            _operations.Set(
                HandleTransitiveRenames(
                    _operations.Get <RenameTableOperation>(),
                    getParentName: op => null,
                    getName: op => op.TableName,
                    getNewName: op => new SchemaQualifiedName(op.NewTableName, op.TableName.Schema),
                    generateTempName: (op) => new SchemaQualifiedName(temporaryNamePrefix + temporaryNameIndex++, op.TableName.Schema),
                    createRenameOperation: (parentName, name, newName)
                    => new RenameTableOperation(name, SchemaQualifiedName.Parse(newName).Name)));

            _operations.Set(
                HandleTransitiveRenames(
                    _operations.Get <RenameColumnOperation>(),
                    getParentName: op => op.TableName,
                    getName: op => op.ColumnName,
                    getNewName: op => op.NewColumnName,
                    generateTempName: (op) => temporaryNamePrefix + temporaryNameIndex++,
                    createRenameOperation: (parentName, name, newName)
                    => new RenameColumnOperation(parentName, name, newName)));

            _operations.Set(
                HandleTransitiveRenames(
                    _operations.Get <RenameIndexOperation>(),
                    getParentName: op => op.TableName,
                    getName: op => op.IndexName,
                    getNewName: op => op.NewIndexName,
                    generateTempName: (op) => temporaryNamePrefix + temporaryNameIndex++,
                    createRenameOperation: (parentName, name, newName)
                    => new RenameIndexOperation(parentName, name, newName)));
        }
        public void Parse_parses_table_name()
        {
            var schemaQualifiedName = SchemaQualifiedName.Parse("A");

            Assert.Equal(null, schemaQualifiedName.Schema);
            Assert.Equal("A", schemaQualifiedName.Name);
        }
        public void Parse_parses_name_with_escaped_delimeters()
        {
            var schemaQualifiedName = SchemaQualifiedName.Parse("[a.]].]]].[.b.[c]]d]");

            Assert.Equal("a.].]", schemaQualifiedName.Schema);
            Assert.Equal(".b.[c]d", schemaQualifiedName.Name);
        }
        public void Parse_parses_schema_dot_table_name()
        {
            var schemaQualifiedName = SchemaQualifiedName.Parse("S.A");

            Assert.Equal("S", schemaQualifiedName.Schema);
            Assert.Equal("A", schemaQualifiedName.Name);
            Assert.True(schemaQualifiedName.IsSchemaQualified);
        }
        public void Delimit_identifier_when_schema_qualified()
        {
            var sqlGenerator = new Mock <MigrationOperationSqlGenerator>(new RelationalTypeMapper())
            {
                CallBase = true
            };

            Assert.Equal("\"foo\".\"bar\"", sqlGenerator.Object.DelimitIdentifier(SchemaQualifiedName.Parse("foo.bar")));
        }
        public void To_string_should_escape_name_when_required()
        {
            var schemaQualifiedName = SchemaQualifiedName.Parse("[a.]].]]].[.b.[c]]d]");

            Assert.Equal("[a.]].]]].[.b.[c]]d]", schemaQualifiedName.ToString());

            schemaQualifiedName = SchemaQualifiedName.Parse("abc.[d.ef]");

            Assert.Equal("abc.[d.ef]", schemaQualifiedName.ToString());
        }
        public void Parse_parses_name_with_delimeters()
        {
            var schemaQualifiedName = SchemaQualifiedName.Parse("[a.].[.b]");

            Assert.Equal("a.", schemaQualifiedName.Schema);
            Assert.Equal(".b", schemaQualifiedName.Name);

            schemaQualifiedName = SchemaQualifiedName.Parse("foo.[bar.baz]");

            Assert.Equal("foo", schemaQualifiedName.Schema);
            Assert.Equal("bar.baz", schemaQualifiedName.Name);

            schemaQualifiedName = SchemaQualifiedName.Parse("[foo.[bar].baz");

            Assert.Equal("foo.[bar", schemaQualifiedName.Schema);
            Assert.Equal("baz", schemaQualifiedName.Name);

            schemaQualifiedName = SchemaQualifiedName.Parse("[foo.[bar.baz]");

            Assert.Null(schemaQualifiedName.Schema);
            Assert.Equal("foo.[bar.baz", schemaQualifiedName.Name);
        }
 public void Parse_throws_for_empty_table_and_schema()
 {
     Assert.Equal(
         Strings.InvalidSchemaQualifiedName("."),
         Assert.Throws <ArgumentException>(() => SchemaQualifiedName.Parse(".")).Message);
 }
 public void Parse_throws_when_too_many_parts()
 {
     Assert.Equal(
         Strings.InvalidSchemaQualifiedName("S1.S2.A"),
         Assert.Throws <ArgumentException>(() => SchemaQualifiedName.Parse("S1.S2.A")).Message);
 }
Esempio n. 10
0
 public void Delimit_identifier_when_schema_qualified()
 {
     Assert.Equal("\"foo\".\"bar\"", SqlGenerator().DelimitIdentifier(SchemaQualifiedName.Parse("foo.bar")));
 }