public void ErrorIsNotReturnedWhenSequenceNameIsSet()
        {
            var expression = new CreateSequenceExpression { Sequence = new SequenceDefinition { Name = "sequence1" } };

            var errors = ValidationHelper.CollectErrors(expression);
            Assert.That(errors.Count, Is.EqualTo(0));
        }
        public void ErrorIsReturnedWhenSequenceNameIsEmptyString()
        {
            var expression = new CreateSequenceExpression { Sequence = new SequenceDefinition { Name = String.Empty } };

            var errors = ValidationHelper.CollectErrors(expression);
            errors.ShouldContain(ErrorMessages.SequenceNameCannotBeNullOrEmpty);
        }
Ejemplo n.º 3
0
        public override string Generate(CreateSequenceExpression expression)
        {
            var result = new StringBuilder(string.Format("CREATE SEQUENCE "));
            var seq = expression.Sequence;

            if (string.IsNullOrEmpty(seq.SchemaName))
            {
                result.AppendFormat(Quoter.QuoteSequenceName(seq.Name));
            }
            else
            {
                result.AppendFormat("{0}.{1}", Quoter.QuoteSchemaName(seq.SchemaName), Quoter.QuoteSequenceName(seq.Name));
            }

            if (seq.Increment.HasValue)
            {
                result.AppendFormat(" INCREMENT BY {0}", seq.Increment);
            }

            if (seq.MinValue.HasValue)
            {
                result.AppendFormat(" MINVALUE {0}", seq.MinValue);
            }

            if (seq.MaxValue.HasValue)
            {
                result.AppendFormat(" MAXVALUE {0}", seq.MaxValue);
            }

            if (seq.StartWith.HasValue)
            {
                result.AppendFormat(" START WITH {0}", seq.StartWith);
            }

            if (seq.Cache.HasValue)
            {
                result.AppendFormat(" CACHE {0}", seq.Cache);
            }

            if (seq.Cycle)
            {
                result.Append(" CYCLE");
            }

            result.Append(";");


            return result.ToString();
        }
 public void CanCreateSequenceWithoutSchema()
 {
     var expression = new CreateSequenceExpression
     {
         Sequence =
         {
             Cache = 10,
             Cycle = true,
             Increment = 2,
             MaxValue = 100,
             MinValue = 0,
             Name = "Sequence",
             StartWith = 2
         }
     };
     var sql = generator.Generate(expression);
     sql.ShouldBe("CREATE SEQUENCE \"Sequence\" INCREMENT 2 MINVALUE 0 MAXVALUE 100 START WITH 2 CACHE 10 CYCLE");
 }
        public void CanAlterSequence()
        {
            var expression = new CreateSequenceExpression
            {
                Sequence =
                {
                    Cache = 10,
                    Cycle = true,
                    Increment = 2,
                    MaxValue = 100,
                    MinValue = 0,
                    Name = "Sequence",
                    SchemaName = "Schema",
                    StartWith = 2
                }
            };

            var result = generator.GenerateAlterSequence(expression.Sequence);
            result.ShouldBe("ALTER SEQUENCE \"Sequence\" RESTART WITH 2");
        }
Ejemplo n.º 6
0
 public override string Generate(CreateSequenceExpression expression)
 {
     truncator.Truncate(expression);
     return String.Format("CREATE SEQUENCE {0}", Quoter.QuoteSequenceName(expression.Sequence.Name));
 }
 public ICreateSequenceInSchemaSyntax Sequence(string sequenceName)
 {
     var expression = new CreateSequenceExpression { Sequence = { Name = sequenceName } };
     _context.Expressions.Add(expression);
     return new CreateSequenceExpressionBuilder(expression);
 }
 public override string Generate(CreateSequenceExpression expression)
 {
     return compatabilityMode.HandleCompatabilty("Sequences are not supported in SqlServer2000");
 }
 public void Truncate(CreateSequenceExpression expression)
 {
     Truncate(expression.Sequence);
 }
Ejemplo n.º 10
0
 public abstract string Generate(CreateSequenceExpression expression);
Ejemplo n.º 11
0
 public override string Generate(CreateSequenceExpression expression)
 {
     return compatabilityMode.HandleCompatabilty("Sequences is not supporteed for MySql");
 }
Ejemplo n.º 12
0
 public void CanCreateSequence()
 {
     var expression = new CreateSequenceExpression
                      {
                          Sequence =
                                  {
                                      Cache = 10,
                                      Cycle = true,
                                      Increment = 2,
                                      MaxValue = 100,
                                      MinValue = 0,
                                      Name = "Sequence",
                                      SchemaName = "Schema",
                                      StartWith = 2
                                  }
                      };
     var sql = generator.Generate(expression);
     sql.ShouldBe("CREATE SEQUENCE \"Sequence\"");
 }
Ejemplo n.º 13
0
 public virtual void Process(CreateSequenceExpression expression)
 {
     Process(Generator.Generate(expression));
 }
 public override string Generate(CreateSequenceExpression expression)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 15
0
 public override string Generate(CreateSequenceExpression expression)
 {
     return String.Format("{0};", base.Generate(expression));
 }