MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / renderCreateMaterializedView

Function renderCreateMaterializedView

pkg/formatter/render.go:806–853  ·  view source on GitHub ↗
(c *ast.CreateMaterializedViewStatement, opts ast.FormatOptions)

Source from the content-addressed store, hash-verified

804}
805
806func renderCreateMaterializedView(c *ast.CreateMaterializedViewStatement, opts ast.FormatOptions) string {
807 if c == nil {
808 return ""
809 }
810 f := newNodeFormatter(opts)
811 sb := f.sb
812
813 sb.WriteString(f.kw("CREATE MATERIALIZED VIEW"))
814 sb.WriteString(" ")
815 if c.IfNotExists {
816 sb.WriteString(f.kw("IF NOT EXISTS"))
817 sb.WriteString(" ")
818 }
819 sb.WriteString(c.Name)
820
821 if len(c.Columns) > 0 {
822 sb.WriteString(" (")
823 sb.WriteString(strings.Join(c.Columns, ", "))
824 sb.WriteString(")")
825 }
826
827 if c.Tablespace != "" {
828 sb.WriteString(" ")
829 sb.WriteString(f.kw("TABLESPACE"))
830 sb.WriteString(" ")
831 sb.WriteString(c.Tablespace)
832 }
833
834 sb.WriteString(" ")
835 sb.WriteString(f.kw("AS"))
836 sb.WriteString(f.clauseSep())
837 sb.WriteString(FormatStatement(c.Query, opts))
838
839 if c.WithData != nil {
840 sb.WriteString(f.clauseSep())
841 if *c.WithData {
842 sb.WriteString(f.kw("WITH DATA"))
843 } else {
844 sb.WriteString(f.kw("WITH NO DATA"))
845 }
846 }
847
848 if opts.AddSemicolon {
849 sb.WriteString(";")
850 }
851
852 return f.result()
853}
854
855func renderRefreshMaterializedView(r *ast.RefreshMaterializedViewStatement, opts ast.FormatOptions) string {
856 if r == nil {

Callers 1

FormatStatementFunction · 0.85

Calls 5

newNodeFormatterFunction · 0.85
FormatStatementFunction · 0.85
kwMethod · 0.80
clauseSepMethod · 0.80
resultMethod · 0.80

Tested by

no test coverage detected