genocall

package
v0.13.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 17, 2023 License: Apache-2.0, UPL-1.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MarkNull = "\u2400" // 0x2400 = nul
	//MarkValid  = "\u6eff" // 0x6eff = fill; full, satisfied
	MarkValid = "Valid" // 0x6eff = fill; full, satisfied
	//MarkHidden = "\u533f"     // 0x533f = hide
	MarkHidden = "_hidden"

	DefaultMaxVARCHARLength = 32767
	DefaultMaxCHARLength    = 10
)
View Source
const (
	DIR_IN    = direction(1)
	DIR_OUT   = direction(2)
	DIR_INOUT = direction(3)
)
View Source
const (
	FLAVOR_SIMPLE = flavor(0)
	FLAVOR_RECORD = flavor(1)
	FLAVOR_TABLE  = flavor(2)
)

Variables

View Source
var (
	SkipMissingTableOf = true

	NumberAsString bool
)
View Source
var Buffers = newBufPool(1 << 16)
View Source
var ErrInvalidArgument = errors.New("invalid argument")
View Source
var ErrMissingTableOf = errors.New("missing TableOf info")
View Source
var MaxTableSize = 128

MaxTableSize is the maximum size of the array elements

View Source
var UnknownSimpleType = errors.New("unknown simple type")

Functions

func CamelCase

func CamelCase(text string) string

func CopyStruct

func CopyStruct(dest interface{}, src interface{}) error

func FilterAndGroup

func FilterAndGroup(userArgs []UserArgument, filter func(string) bool) (filteredArgs [][]UserArgument, err error)

func MustOpenCsv

func MustOpenCsv(filename string) *os.File

MustOpenCsv opens the file, or panics on error

func OpenCsv

func OpenCsv(filename string) (*os.File, error)

OpenCsv opens the filename

func ParseDigits

func ParseDigits(s string, precision, scale int) error

func ParseDocs

func ParseDocs(ctx context.Context, text string) (map[string]string, error)

func ReadDB

func ReadDB(ctx context.Context, db querier, pattern string, filter func(string) bool) (functions []Function, annotations []Annotation, err error)

func ReplOraPh

func ReplOraPh(s string, params []interface{}) string

func SaveFunctionTests

func SaveFunctionTests(dst io.Writer, functions []Function, pkg, pbImport string, saveStructs bool) error

func SaveFunctions

func SaveFunctions(dst io.Writer, functions []Function, pkg, pbImport string, saveStructs bool) error

func SaveProtobuf

func SaveProtobuf(dst io.Writer, functions []Function, pkg string) error

func SetLogger

func SetLogger(lgr *slog.Logger)

func UnoCap

func UnoCap(text string) string

Types

type Annotation

type Annotation struct {
	Package, Type, Name, Other string
	Size                       int
}

func ParseAnnotationsAndDocs

func ParseAnnotationsAndDocs(ctx context.Context, packageName, src string) ([]Annotation, map[string]string, error)

func (Annotation) FullName

func (a Annotation) FullName() string

func (Annotation) FullOther

func (a Annotation) FullOther() string

func (Annotation) String

func (a Annotation) String() string

type Argument

type Argument struct {
	RecordOf       []NamedArgument //this argument is a record (map) of this type
	Name           string
	Type, TypeName string
	AbsType        string
	Charset        string
	Charlength     uint
	TableOf        *Argument // this argument is a table (array) of this type

	PlsType
	Flavor    flavor
	Direction direction
	Precision uint8
	Scale     uint8
	// contains filtered or unexported fields
}

func NewArgument

func NewArgument(name, dataType, plsTypeName, typeName, dirName string, dir direction,
	charset string, precision, scale uint8, charlength uint, typ *PlsType) Argument

func (Argument) IsInput

func (a Argument) IsInput() bool

func (Argument) IsOutput

func (a Argument) IsOutput() bool

func (Argument) String

func (a Argument) String() string

type Function

type Function struct {
	Package, Name, Alias string
	Returns              *Argument  `json:",omitempty"`
	Args                 []Argument `json:",omitempty"`
	Documentation        string     `json:",omitempty"`
	Replacement          *Function  `json:",omitempty"`
	ReplacementIsJSON    bool       `json:",omitempty"`
	LastDDL              time.Time  `json:",omitempty"`
	// contains filtered or unexported fields
}

func ApplyAnnotations

func ApplyAnnotations(functions []Function, annotations []Annotation) []Function

func ParseArguments

func ParseArguments(userArgs [][]UserArgument, filter func(string) bool, types map[TypeName]*PlsType) (functions []Function, err error)

func ParseCsv

func ParseCsv(r io.Reader, filter func(string) bool) (functions []Function, err error)

ParseCsv parses the csv

func ParseCsvFile

func ParseCsvFile(filename string, filter func(string) bool) (functions []Function, err error)

ParseCsv reads the given csv file as user_arguments The csv should be an export of

SELECT object_id, subprogram_id, package_name, sequence, object_name,
       data_level, argument_name, in_out,
       data_type, data_precision, data_scale, character_set_name,
       pls_type, char_length, type_owner, type_name, type_subname, type_link
  FROM user_arguments
  ORDER BY object_id, subprogram_id, SEQUENCE;

func (Function) AliasedName

func (f Function) AliasedName() string

func (Function) FullName

func (f Function) FullName() string

func (Function) GenChecks

func (f Function) GenChecks(w io.Writer) (string, error)

func (Function) HasCursorOut

func (f Function) HasCursorOut() bool

func (Function) PlsqlBlock

func (fun Function) PlsqlBlock(checkName string) (plsql, callFun string)

SavePlsqlBlock saves the plsql block definition into writer

func (Function) RealName

func (f Function) RealName() string

func (Function) SaveProtobuf

func (f Function) SaveProtobuf(dst io.Writer, seen map[string]struct{}) error

func (Function) SaveStruct

func (f Function) SaveStruct(dst io.Writer, out bool) error

func (Function) String

func (f Function) String() string

type NamedArgument

type NamedArgument struct {
	Name string
	*Argument
}

type PlsType

type PlsType struct {
	TypeName
	Attr                       string
	Charset, IndexBy, TypeCode string
	Length, Prec, Scale        sql.NullInt64
	CollectionOf               *PlsType
	RecordOf                   []*PlsType
}

func (PlsType) FromOra

func (arg PlsType) FromOra(dst, src, varName string) string

FromOra retrieves the value of the argument with arg type, from src variable to dst variable.

func (PlsType) GetOra

func (arg PlsType) GetOra(src, varName string) string

func (PlsType) String

func (arg PlsType) String() string

func (PlsType) ToOra

func (arg PlsType) ToOra(dst, src string, dir direction) (expr string, variable string)

ToOra adds the value of the argument with arg type, from src variable to dst variable.

type TypeName

type TypeName struct {
	Owner, Package, Name string
}

func (TypeName) String

func (tn TypeName) String() string

type UserArgument

type UserArgument struct {
	PackageName string    `sql:"PACKAGE_NAME"`
	ObjectName  string    `sql:"OBJECT_NAME"`
	LastDDL     time.Time `json:",omitempty"`

	ArgumentName string `sql:"ARGUMENT_NAME"`
	InOut        string `sql:"IN_OUT"`

	DataType string `sql:"DATA_TYPE"`

	CharacterSetName string `sql:"CHARACTER_SET_NAME" json:",omitempty"`

	PlsType     string `sql:"PLS_TYPE" json:",omitempty"`
	TypeLink    string `sql:"TYPE_LINK" json:",omitempty"`
	TypeOwner   string `sql:"TYPE_OWNER" json:",omitempty"`
	TypeName    string `sql:"TYPE_NAME" json:",omitempty"`
	TypeSubname string `sql:"TYPE_SUBNAME" json:",omitempty"`

	ObjectID     uint `sql:"OBJECT_ID" json:",omitempty"`
	SubprogramID uint `sql:"SUBPROGRAM_ID" json:",omitempty"`

	CharLength uint `sql:"CHAR_LENGTH" json:"CharLength,omitempty"`
	Position   uint `sql:"POSITION" json:",omitempty"`

	DataPrecision uint8 `sql:"DATA_PRECISION" json:",omitempty"`
	DataScale     uint8 `sql:"DATA_SCALE" json:",omitempty"`
	DataLevel     uint8 `sql:"DATA_LEVEL" json:",omitempty"`
}

UserArgument represents the required info from the user_arguments view

func ReadCsv

func ReadCsv(r io.Reader) (userArgs []UserArgument, err error)

ReadCsv reads the csv from the Reader, and sends the arguments to the given channel.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL