コード例 #1
0
 public override void ExplicitVisit(CheckConstraintDefinition node)
 {
     if (node.ConstraintIdentifier != null)
     {
         node.ConstraintIdentifier.Accept(this);
     }
     else
     {
         _buffer.Append($"\"check_{Guid.NewGuid().ToString("N").ToLower()}\"");
     }
     _buffer.Append(" check (");
     node.CheckCondition.Accept(this);
     _buffer.Append(")");
 }
コード例 #2
0
ファイル: AllNodesVisitor.cs プロジェクト: yaakoviyun/sqlskim
 public override void Visit(CheckConstraintDefinition node) { this.action(node); }
コード例 #3
0
 public override void ExplicitVisit(CheckConstraintDefinition fragment)
 {
     _fragments.Add(fragment);
 }
コード例 #4
0
        public void ProcessCreateTable(CreateTableStatement TblStmt)
        {
            bool isTemp = TblStmt.SchemaObjectName.BaseIdentifier.Value.StartsWith("#") ||
                          TblStmt.SchemaObjectName.BaseIdentifier.Value.StartsWith("@");


            if (TblStmt.SchemaObjectName.SchemaIdentifier == null &&
                !isTemp
                )
            {
                _smells.SendFeedBack(27, TblStmt);
            }
            {
                foreach (ColumnDefinition colDef in TblStmt.Definition.ColumnDefinitions)
                {
                    _smells.ProcessTsqlFragment(colDef);
                }
            }

            if (isTemp)
            {
                foreach (ConstraintDefinition constDef in TblStmt.Definition.TableConstraints)
                {
                    if (constDef.ConstraintIdentifier != null)
                    {
                    }
                    switch (FragmentTypeParser.GetFragmentType(constDef))
                    {
                    case "UniqueConstraintDefinition":
                        UniqueConstraintDefinition unqConst = (UniqueConstraintDefinition)constDef;
                        if (unqConst.IsPrimaryKey)
                        {
                            _smells.SendFeedBack(38, constDef);
                        }
                        break;
                    }
                }
                foreach (ColumnDefinition colDef in TblStmt.Definition.ColumnDefinitions)
                {
                    if (colDef.DefaultConstraint != null && colDef.DefaultConstraint.ConstraintIdentifier != null)
                    {
                        _smells.SendFeedBack(39, colDef);
                    }
                    foreach (ConstraintDefinition constDef in colDef.Constraints)
                    {
                        if (constDef.ConstraintIdentifier != null)
                        {
                        }
                        switch (FragmentTypeParser.GetFragmentType(constDef))
                        {
                        case "CheckConstraintDefinition":
                            CheckConstraintDefinition chkConst = (CheckConstraintDefinition)constDef;
                            if (chkConst.ConstraintIdentifier != null)
                            {
                                _smells.SendFeedBack(40, chkConst);;
                            }
                            break;
                        }
                    }
                }
            }
        }