mysql

package
v0.0.0-...-f82f9f2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AliasMap = map[string]string{
	"INTEGER":           "INT",
	"BOOL":              "BOOLEAN",
	"DEC":               "DECIMAL",
	"FIXED":             "DECIMAL",
	"NUMERIC":           "DECIMAL",
	"DOUBLE PRECISION":  "DOUBLE",
	"REAL":              "DOUBLE",
	"CHARACTER":         "CHAR",
	"CHARACTER VARYING": "VARCHAR",
}

AliasMap maps MySQL type aliases to their canonical names. All keys and values are UPPERCASE.

View Source
var TypeDefinitions = []engine.TypeDefinition{
	{ID: "TINYINT", Label: "TINYINT", Category: engine.TypeCategoryNumeric},
	{ID: "SMALLINT", Label: "SMALLINT", Category: engine.TypeCategoryNumeric},
	{ID: "MEDIUMINT", Label: "MEDIUMINT", Category: engine.TypeCategoryNumeric},
	{ID: "INT", Label: "INT", Category: engine.TypeCategoryNumeric},
	{ID: "BIGINT", Label: "BIGINT", Category: engine.TypeCategoryNumeric},
	{ID: "DECIMAL", Label: "DECIMAL", HasPrecision: true, DefaultPrecision: engine.IntPtr(10), Category: engine.TypeCategoryNumeric},
	{ID: "FLOAT", Label: "FLOAT", Category: engine.TypeCategoryNumeric},
	{ID: "DOUBLE", Label: "DOUBLE", Category: engine.TypeCategoryNumeric},
	{ID: "VARCHAR", Label: "VARCHAR", HasLength: true, DefaultLength: engine.IntPtr(255), Category: engine.TypeCategoryText},
	{ID: "CHAR", Label: "CHAR", HasLength: true, DefaultLength: engine.IntPtr(1), Category: engine.TypeCategoryText},
	{ID: "TINYTEXT", Label: "TINYTEXT", Category: engine.TypeCategoryText},
	{ID: "TEXT", Label: "TEXT", Category: engine.TypeCategoryText},
	{ID: "MEDIUMTEXT", Label: "MEDIUMTEXT", Category: engine.TypeCategoryText},
	{ID: "LONGTEXT", Label: "LONGTEXT", Category: engine.TypeCategoryText},
	{ID: "BINARY", Label: "BINARY", HasLength: true, DefaultLength: engine.IntPtr(1), Category: engine.TypeCategoryBinary},
	{ID: "VARBINARY", Label: "VARBINARY", HasLength: true, DefaultLength: engine.IntPtr(255), Category: engine.TypeCategoryBinary},
	{ID: "TINYBLOB", Label: "TINYBLOB", Category: engine.TypeCategoryBinary},
	{ID: "BLOB", Label: "BLOB", Category: engine.TypeCategoryBinary},
	{ID: "MEDIUMBLOB", Label: "MEDIUMBLOB", Category: engine.TypeCategoryBinary},
	{ID: "LONGBLOB", Label: "LONGBLOB", Category: engine.TypeCategoryBinary},
	{ID: "DATE", Label: "DATE", Category: engine.TypeCategoryDatetime},
	{ID: "TIME", Label: "TIME", Category: engine.TypeCategoryDatetime},
	{ID: "DATETIME", Label: "DATETIME", Category: engine.TypeCategoryDatetime},
	{ID: "TIMESTAMP", Label: "TIMESTAMP", Category: engine.TypeCategoryDatetime},
	{ID: "YEAR", Label: "YEAR", Category: engine.TypeCategoryDatetime},
	{ID: "BOOLEAN", Label: "BOOL", Category: engine.TypeCategoryBoolean},
	{ID: "JSON", Label: "JSON", Category: engine.TypeCategoryJSON},
	{ID: "ENUM", Label: "ENUM", Category: engine.TypeCategoryOther},
	{ID: "SET", Label: "SET", Category: engine.TypeCategoryOther},
}

TypeDefinitions contains the canonical MySQL types with metadata for UI.

Functions

func NewMyMariaDBPlugin

func NewMyMariaDBPlugin() *engine.Plugin

func NewMySQLPlugin

func NewMySQLPlugin() *engine.Plugin

func NewMySQLSQLBuilder

func NewMySQLSQLBuilder(db *gorm.DB, plugin gorm_plugin.GormPluginFunctions) gorm_plugin.SQLBuilderInterface

NewMySQLSQLBuilder creates a new MySQL-specific SQL builder

func NormalizeType

func NormalizeType(typeName string) string

NormalizeType converts a MySQL type alias to its canonical form.

Types

type MySQLPlugin

type MySQLPlugin struct {
	gorm_plugin.GormPlugin
}

func (*MySQLPlugin) BuildSkipConflictClause

func (p *MySQLPlugin) BuildSkipConflictClause(pkColumns []string) clause.OnConflict

BuildSkipConflictClause returns ON DUPLICATE KEY UPDATE pk = pk for MySQL. MySQL's GORM driver can't generate the id=id fallback without schema info when using .Table() with map records, so we provide explicit identity assignments.

func (*MySQLPlugin) CreateSQLBuilder

func (p *MySQLPlugin) CreateSQLBuilder(db *gorm.DB) gorm_plugin.SQLBuilderInterface

CreateSQLBuilder creates a MySQL-specific SQL builder

func (*MySQLPlugin) DB

func (p *MySQLPlugin) DB(config *engine.PluginConfig) (*gorm.DB, error)

func (*MySQLPlugin) FormatGeometryValue

func (p *MySQLPlugin) FormatGeometryValue(rawBytes []byte, columnType string) string

FormatGeometryValue formats MySQL geometry data for display. MySQL stores geometry as WKB with a 4-byte SRID prefix.

func (*MySQLPlugin) GetAllSchemasQuery

func (p *MySQLPlugin) GetAllSchemasQuery() string

func (*MySQLPlugin) GetColumnConstraints

func (p *MySQLPlugin) GetColumnConstraints(config *engine.PluginConfig, schema string, storageUnit string) (map[string]map[string]any, error)

GetColumnConstraints retrieves column constraints for MySQL/MariaDB tables

func (*MySQLPlugin) GetCreateTableQuery

func (p *MySQLPlugin) GetCreateTableQuery(db *gorm.DB, schema string, storageUnit string, columns []engine.Record) string

func (*MySQLPlugin) GetDatabaseMetadata

func (p *MySQLPlugin) GetDatabaseMetadata() *engine.DatabaseMetadata

GetDatabaseMetadata returns MySQL/MariaDB metadata for frontend configuration.

func (*MySQLPlugin) GetDatabases

func (p *MySQLPlugin) GetDatabases(config *engine.PluginConfig) ([]string, error)

func (*MySQLPlugin) GetForeignKeyRelationships

func (p *MySQLPlugin) GetForeignKeyRelationships(config *engine.PluginConfig, schema string, storageUnit string) (map[string]*engine.ForeignKeyRelationship, error)

func (*MySQLPlugin) GetGraphQueryDB

func (p *MySQLPlugin) GetGraphQueryDB(db *gorm.DB, schema string) *gorm.DB

func (*MySQLPlugin) GetLastInsertID

func (p *MySQLPlugin) GetLastInsertID(db *gorm.DB) (int64, error)

GetLastInsertID returns the most recently auto-generated ID using MySQL's LAST_INSERT_ID().

func (*MySQLPlugin) GetPlaceholder

func (p *MySQLPlugin) GetPlaceholder(index int) string

func (*MySQLPlugin) GetPrimaryKeyColQuery

func (p *MySQLPlugin) GetPrimaryKeyColQuery() string

func (*MySQLPlugin) GetSSLStatus

func (p *MySQLPlugin) GetSSLStatus(config *engine.PluginConfig) (*engine.SSLStatus, error)

GetSSLStatus queries MySQL/MariaDB to get the actual SSL status of the connection. Checks the Ssl_cipher session variable. Results are cached.

func (*MySQLPlugin) GetStorageUnitExistsQuery

func (p *MySQLPlugin) GetStorageUnitExistsQuery() string

func (*MySQLPlugin) GetSupportedOperators

func (p *MySQLPlugin) GetSupportedOperators() map[string]string

func (*MySQLPlugin) GetTableInfoQuery

func (p *MySQLPlugin) GetTableInfoQuery() string

func (*MySQLPlugin) GetTableNameAndAttributes

func (p *MySQLPlugin) GetTableNameAndAttributes(rows *sql.Rows) (string, []engine.Record)

func (*MySQLPlugin) MarkGeneratedColumns

func (p *MySQLPlugin) MarkGeneratedColumns(config *engine.PluginConfig, schema string, storageUnit string, columns []engine.Column) error

MarkGeneratedColumns detects MySQL generated columns (VIRTUAL or STORED) and marks them as IsComputed.

func (*MySQLPlugin) NormalizeType

func (p *MySQLPlugin) NormalizeType(typeName string) string

NormalizeType converts MySQL type aliases to their canonical form.

func (*MySQLPlugin) RawExecute

func (p *MySQLPlugin) RawExecute(config *engine.PluginConfig, query string, params ...any) (*engine.GetRowsResult, error)

type MySQLSQLBuilder

type MySQLSQLBuilder struct {
	*gorm_plugin.SQLBuilder
}

MySQLSQLBuilder extends the base SQLBuilder with MySQL-specific behavior

func (*MySQLSQLBuilder) GetTableQuery

func (msb *MySQLSQLBuilder) GetTableQuery(schema, table string) *gorm.DB

GetTableQuery creates a GORM query with the appropriate table reference for MySQL/MariaDB

Jump to

Keyboard shortcuts

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