예제 #1
0
        private static void ParseAddConstraint(Parser parser, PgTable table, PgSchema schema)
        {
            var constraintName = ParserUtils.GetObjectName(parser.ParseIdentifier());
            var constraint     = new PgConstraint(constraintName);

            constraint.TableName = table.Name;
            table.AddConstraint(constraint);

            if (parser.ExpectOptional("PRIMARY", "KEY"))
            {
                schema.AddPrimaryKey(constraint);
                constraint.Definition = "PRIMARY KEY " + parser.GetExpression();
            }
            else
            {
                constraint.Definition = parser.GetExpression();
            }
        }