...

Source file src/github.com/ory/x/pkgerx/sql_template_funcs.go

Documentation: github.com/ory/x/pkgerx

     1  package pkgerx
     2  
     3  import (
     4  	"fmt"
     5  	"regexp"
     6  )
     7  
     8  var SQLTemplateFuncs = map[string]interface{}{
     9  	"identifier": Identifier,
    10  }
    11  
    12  var identifierPattern = regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9_]*$")
    13  
    14  func Identifier(i string) (string, error) {
    15  	if !identifierPattern.MatchString(i) {
    16  		return "", fmt.Errorf("invalid SQL identifier '%s'", i)
    17  	}
    18  	return i, nil
    19  }
    20  

View as plain text