public override void ExplicitVisit(AlterTableDropTableElementStatement node) { PgExpressionVisitor expressionVisitor = new PgExpressionVisitor(_buffer); for (int index = 0, count = node.AlterTableDropTableElements.Count - 1; index <= count; ++index) { _buffer.Append("alter table "); node.SchemaObjectName.Accept(expressionVisitor); AlterTableDropTableElement element = node.AlterTableDropTableElements[index]; _buffer.Append(" drop "); if (element.IsIfExists) { _buffer.Append("if exists "); } switch (element.TableElementType) { case TableElementType.Constraint: _buffer.Append("constraint "); element.Name.Accept(expressionVisitor); _buffer.AppendLine(";"); break; default: throw new InvalidOperationException("unsupported table element name"); } } }
public override void ExplicitVisit(IfStatement node) { if (_state != PgTranslatorState.Postdeplyment && _state != PgTranslatorState.Deployment) { return; } _buffer.Append("if "); PgExpressionVisitor visitor = new PgExpressionVisitor(_buffer); node.Predicate.Accept(visitor); _buffer.Append(" then"); _buffer.AppendLine(); node.ThenStatement.Accept(visitor); if (node.ElseStatement != null) { _buffer.AppendLine("else"); node.ElseStatement.Accept(visitor); } _buffer.AppendLine("end if;"); }
public override void ExplicitVisit(CreateSchemaStatement node) { _buffer.Append("create schema "); PgExpressionVisitor visitor = new PgExpressionVisitor(_buffer); node.Name.Accept(visitor); _buffer.Append(";"); _buffer.AppendLine(); }
public override void ExplicitVisit(DropSchemaStatement node) { _buffer.Append("drop schema "); PgExpressionVisitor visitor = new PgExpressionVisitor(_buffer); if (node.IsIfExists) { _buffer.Append("if exists "); } node.Schema.Accept(visitor); _buffer.AppendLine(";"); }
public override void ExplicitVisit(DropTableStatement node) { PgExpressionVisitor expressionVisitor = new PgExpressionVisitor(_buffer); for (int index = 0, count = node.Objects.Count - 1; index <= count; ++index) { _buffer.Append("drop table"); if (node.IsIfExists) { _buffer.Append(" if exists"); } _buffer.Append(" "); node.Objects[index].Accept(expressionVisitor); _buffer.AppendLine(";"); } }
public override void ExplicitVisit(ExecuteSpecification node) { if (node.ExecuteContext != null) { throw new NotSupportedException(); } if (node.LinkedServer != null) { throw new NotSupportedException(); } if (node.Variable != null) { throw new NotSupportedException(); } if (node.ExecutableEntity is ExecutableProcedureReference procedureReference) { PgExpressionVisitor expressionVisitor = new PgExpressionVisitor(_buffer); procedureReference.ProcedureReference.Accept(expressionVisitor); _buffer.Append("("); for (int index = 0, count = procedureReference.Parameters.Count - 1; index <= count; ++index) { ExecuteParameter parameter = procedureReference.Parameters[index]; parameter.Accept(expressionVisitor); if (index < count) { _buffer.Append(", "); } } _buffer.Append(")"); } else { throw new NotSupportedException(); } }