snapshot of https://github.com/sqlc-dev/sqlc.git (main, 2026-09-16; blobs > 131072B omitted)
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
This commit is contained in:
47
internal/sql/ast/create_function_stmt.go
Normal file
47
internal/sql/ast/create_function_stmt.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package ast
|
||||
|
||||
import "github.com/sqlc-dev/sqlc/internal/sql/format"
|
||||
|
||||
type CreateFunctionStmt struct {
|
||||
Tag NodeTag[CreateFunctionStmt] `json:"tag"`
|
||||
|
||||
Replace bool `json:"replace"`
|
||||
Params *List `json:"params,omitempty"`
|
||||
ReturnType *TypeName `json:"return_type,omitempty"`
|
||||
Func *FuncName `json:"func,omitempty"`
|
||||
// TODO: Understand these two fields
|
||||
Options *List `json:"options,omitempty"`
|
||||
WithClause *List `json:"with_clause,omitempty"`
|
||||
}
|
||||
|
||||
func (n *CreateFunctionStmt) Pos() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (n *CreateFunctionStmt) Format(buf *TrackedBuffer, d format.Dialect) {
|
||||
if n == nil {
|
||||
return
|
||||
}
|
||||
buf.WriteString("CREATE ")
|
||||
if n.Replace {
|
||||
buf.WriteString("OR REPLACE ")
|
||||
}
|
||||
buf.WriteString("FUNCTION ")
|
||||
buf.astFormat(n.Func, d)
|
||||
buf.WriteString("(")
|
||||
if items(n.Params) {
|
||||
buf.join(n.Params, d, ", ")
|
||||
}
|
||||
buf.WriteString(")")
|
||||
if n.ReturnType != nil {
|
||||
buf.WriteString(" RETURNS ")
|
||||
buf.astFormat(n.ReturnType, d)
|
||||
}
|
||||
// Format options (AS, LANGUAGE, etc.)
|
||||
if items(n.Options) {
|
||||
for _, opt := range n.Options.Items {
|
||||
buf.WriteString(" ")
|
||||
buf.astFormat(opt, d)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user