tosql

package
v1.0.48 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Combinations

func Combinations(set []string) (subsets [][]string)

func EntityPrimaryKeys

func EntityPrimaryKeys(entity *nemgen.Entity) []*nemgen.Field

func FieldTypeToMYSQL

func FieldTypeToMYSQL(f *nemgen.Field) string

func FieldTypeToPG

func FieldTypeToPG(f *nemgen.Field) string

func GenerateFile

func GenerateFile(ctx context.Context, req *GenerateFileRequest) error

func MapEntityToTypes

func MapEntityToTypes(e *nemgen.Entity, projectVersion *nemgen.ProjectVersion, dbType db.DBType) ([]SchemaField, []SchemaIndex, []SchemaConstraint)

func PrintEntities added in v1.0.42

func PrintEntities(message string, entities []*nemgen.Entity)

func SortStandaloneEntities added in v1.0.41

func SortStandaloneEntities(pv *nemgen.ProjectVersion)

Types

type Action

type Action string
const (
	SelectSimpleAction             Action = "select_simple"
	SelectForIndexedSimpleAction   Action = "select_indexed_simple"
	SelectForIndexedCombinedAction Action = "select_indexed_combined"
	InsertAction                   Action = "insert"
	UpdateAction                   Action = "update"
	DeleteAction                   Action = "delete"
	CreateAction                   Action = "create"
)

type ActionResult

type ActionResult struct {
	Action Action
	Data   string
}

type ConfigValues

type ConfigValues struct {
	DBType   db.DBType `json:"db_type"`
	Entities []string  `json:"entities"`
	Actions  []Action  `json:"actions"`
}

func ConfigValuesFromAny added in v1.0.1

func ConfigValuesFromAny(any interface{}) (*ConfigValues, error)

type GenerateFileRequest

type GenerateFileRequest struct {
	ExecutionUUID string
	Configvalues  *ConfigValues
	Data          SchemaTemplate
	ActionResults *[]ActionResult
	Action        Action
	// contains filtered or unexported fields
}

type GenerateRequest

type GenerateRequest struct {
	ExecutionUUID  string
	ProjectVersion *nemgen.ProjectVersion
	Configvalues   *ConfigValues
}

type GenerateResponse

type GenerateResponse struct {
	ExecutionUUID string
	WorkingDir    string
	ZipFile       string
	Results       []ActionResult
}

func GenerateSQL added in v1.0.4

func GenerateSQL(ctx context.Context, req GenerateRequest) (*GenerateResponse, error)

type SchemaConstraint

type SchemaConstraint struct {
	DBType       db.DBType
	Name         string
	Relationship *nemgen.Relationship
	TableName    string
	FromFields   []SchemaField
	ToFields     []SchemaField
	HasComma     bool
}

contraints

func (SchemaConstraint) ForeignKeyFields

func (sc SchemaConstraint) ForeignKeyFields() string

func (SchemaConstraint) ReferenceFields

func (sc SchemaConstraint) ReferenceFields() string

type SchemaEntity

type SchemaEntity struct {
	DBType           db.DBType
	Name             string
	NameTitle        string
	PrimaryKeys      []string
	Fields           []SchemaField
	Indexes          []SchemaIndex
	Constraints      []SchemaConstraint
	SelectStatements []SchemaSelectStatement
}

entity

func (SchemaEntity) IsPrimaryKey

func (e SchemaEntity) IsPrimaryKey(fieldIdentifier string) bool

func (SchemaEntity) PrimaryKeysIdentifiers

func (e SchemaEntity) PrimaryKeysIdentifiers() string

func (SchemaEntity) PrimaryKeysWhereClause

func (e SchemaEntity) PrimaryKeysWhereClause() string

func (SchemaEntity) UpdateFields

func (e SchemaEntity) UpdateFields() string

type SchemaField

type SchemaField struct {
	Name      string
	NameTitle string
	Type      string
	Field     *nemgen.Field
	Null      string
	HasComma  bool
	Default   string
	Unique    string
}

field

func (SchemaField) Postfix

func (f SchemaField) Postfix() string

type SchemaIndex

type SchemaIndex struct {
	DBType     db.DBType
	Name       string
	FieldNames map[string]string
	Index      *nemgen.Index
	TypePrefix string
	Type       string
	TypeSort   int
	HasComma   bool
}

index

func (SchemaIndex) FieldNamesIdentifiers

func (i SchemaIndex) FieldNamesIdentifiers() string

type SchemaSelectStatement

type SchemaSelectStatement struct {
	Name             string
	Identifier       string
	EntityIdentifier string
	Fields           []SchemaSelectStatementField
	CombinedIndexes  bool
	IsPrimary        bool
	TimeFields       []SchemaField
	SortSupported    bool
}

select

func ResolveSelectStatements

func ResolveSelectStatements(e *nemgen.Entity, dbType db.DBType) []SchemaSelectStatement

type SchemaSelectStatementField

type SchemaSelectStatementField struct {
	Name   string
	Field  SchemaField
	IsLast bool
}

type SchemaTemplate

type SchemaTemplate struct {
	Entities []SchemaEntity
}

Jump to

Keyboard shortcuts

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