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

Method SQL

pkg/sql/ast/sql.go:987–1017  ·  view source on GitHub ↗

SQL returns the full SQL string for this CREATE VIEW statement including the optional OR REPLACE, TEMPORARY, IF NOT EXISTS, column list, SELECT query, and WITH CHECK OPTION clause.

()

Source from the content-addressed store, hash-verified

985// optional OR REPLACE, TEMPORARY, IF NOT EXISTS, column list, SELECT query,
986// and WITH CHECK OPTION clause.
987func (c *CreateViewStatement) SQL() string {
988 if c == nil {
989 return ""
990 }
991 sb := getBuilder()
992 defer putBuilder(sb)
993 sb.WriteString("CREATE ")
994 if c.OrReplace {
995 sb.WriteString("OR REPLACE ")
996 }
997 if c.Temporary {
998 sb.WriteString("TEMPORARY ")
999 }
1000 sb.WriteString("VIEW ")
1001 if c.IfNotExists {
1002 sb.WriteString("IF NOT EXISTS ")
1003 }
1004 sb.WriteString(c.Name)
1005 if len(c.Columns) > 0 {
1006 sb.WriteString(" (")
1007 sb.WriteString(strings.Join(c.Columns, ", "))
1008 sb.WriteString(")")
1009 }
1010 sb.WriteString(" AS ")
1011 sb.WriteString(stmtSQL(c.Query))
1012 if c.WithOption != "" {
1013 sb.WriteString(" WITH ")
1014 sb.WriteString(c.WithOption)
1015 }
1016 return sb.String()
1017}
1018
1019// SQL returns the full SQL string for this CREATE MATERIALIZED VIEW statement.
1020func (c *CreateMaterializedViewStatement) SQL() string {

Callers 2

TestNilSQLFunction · 0.95

Calls 4

getBuilderFunction · 0.85
putBuilderFunction · 0.85
stmtSQLFunction · 0.70
StringMethod · 0.45

Tested by 2

TestNilSQLFunction · 0.76