dm

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2023 License: Apache-2.0 Imports: 20 Imported by: 0

README

GORM DM8 Driver

达梦数据库gorm驱动

Quick Start

import (
  "github.com/jiangliuhong/gorm-driver-dm"
  "gorm.io/gorm"
)

// https://github.com/jiangliuhong/gorm-driver-dm
dsn := "dm://SYSDBA:SYSDBA@127.0.0.1:5236?autoCommit=true"
db, err := gorm.Open(dm.Open(dsn), &gorm.Config{})

达梦数据库用户名即模式名

入门

  • clone本项目到本地,进入项目目录,打开dm_test.go
  • 修改dsn调整为本地正确信息
  • 运行go test -v
  • 如果无报错,参考dm_test.go使用即可

注意事项

  • 超过4096长度字符串,需要使用dmSchema.Clob,不超过使用string即可
  • 列名不要使用达梦关键字,否则会出现错误

修改BUG

  • 解决达梦双单引号转义问题

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ReservedWords = hashset.New(funk.Map(ReservedWordsList, func(s string) interface{} { return s }).([]interface{})...)
View Source
var ReservedWordsList = []string{}/* 156 elements not displayed */

Functions

func BuildQuerySQL

func BuildQuerySQL(db *gorm.DB)

func BuildReservedWord

func BuildReservedWord(v string) string

func ConvertMysqlSql

func ConvertMysqlSql(sql string) string

ConvertMysqlSql 兼容mysql的sql 将 ` 转为 "

func ConvertNameToFormat

func ConvertNameToFormat(x string) string

func Create

func Create(db *gorm.DB)

func Delete

func Delete(config *callbacks.Config) func(db *gorm.DB)

func ExplainSQL

func ExplainSQL(sql string, numericPlaceholder *regexp.Regexp, escaper string, avars ...interface{}) string

ExplainSQL generate SQL string with given parameters, the generated SQL is expected to be used in logger, execute it might introduce a SQL injection vulnerability

func IsReservedWord

func IsReservedWord(v string) bool

func New

func New(config Config) gorm.Dialector

func Open

func Open(dsn string) gorm.Dialector

func Query

func Query(db *gorm.DB)

func RefClone

func RefClone(inter interface{}) interface{}

func RefInclude

func RefInclude(inter interface{}, inc []string) interface{}

func RemoveReservedWordSymbol

func RemoveReservedWordSymbol(v string) string

func ReplacementQuote

func ReplacementQuote(value string)

func RowQuery

func RowQuery(db *gorm.DB)

func TB

func TB(db *gorm.DB)

func Update

func Update(config *callbacks.Config) func(db *gorm.DB)

Types

type BuildIndexOptionsInterface

type BuildIndexOptionsInterface interface {
	BuildIndexOptions([]schema.IndexOption, *gorm.Statement) []interface{}
}

type ColumnType

type ColumnType struct {
	// contains filtered or unexported fields
}

func (ColumnType) AutoIncrement

func (c ColumnType) AutoIncrement() (isAutoIncrement bool, ok bool)

func (ColumnType) ColumnType

func (c ColumnType) ColumnType() (columnType string, ok bool)

func (ColumnType) Comment

func (c ColumnType) Comment() (value string, ok bool)

func (ColumnType) DatabaseTypeName

func (c ColumnType) DatabaseTypeName() string

func (ColumnType) DecimalSize

func (c ColumnType) DecimalSize() (precision int64, scale int64, ok bool)

func (ColumnType) DefaultValue

func (c ColumnType) DefaultValue() (value string, ok bool)

func (ColumnType) Length

func (c ColumnType) Length() (length int64, ok bool)

func (ColumnType) Name

func (c ColumnType) Name() string

func (ColumnType) Nullable

func (c ColumnType) Nullable() (nullable bool, ok bool)

func (ColumnType) PrimaryKey

func (c ColumnType) PrimaryKey() (isPrimaryKey bool, ok bool)

func (ColumnType) ScanType

func (c ColumnType) ScanType() reflect.Type

func (ColumnType) Unique

func (c ColumnType) Unique() (unique bool, ok bool)

type Config

type Config struct {
	DriverName        string
	DSN               string
	Conn              *sql.DB
	DefaultStringSize uint
}

type Dialector

type Dialector struct {
	*Config
}

func (Dialector) BindVarTo

func (d Dialector) BindVarTo(writer clause.Writer, stmt *gorm.Statement, v interface{})

func (Dialector) ClauseBuilders

func (d Dialector) ClauseBuilders() map[string]clause.ClauseBuilder

func (Dialector) DataTypeOf

func (d Dialector) DataTypeOf(field *schema.Field) string

func (Dialector) DefaultValueOf

func (d Dialector) DefaultValueOf(*schema.Field) clause.Expression

func (Dialector) DummyTableName

func (d Dialector) DummyTableName() string

func (Dialector) Explain

func (d Dialector) Explain(sql string, vars ...interface{}) string

func (Dialector) Initialize

func (d Dialector) Initialize(db *gorm.DB) (err error)

func (Dialector) Migrator

func (d Dialector) Migrator(db *gorm.DB) gorm.Migrator

func (Dialector) Name

func (d Dialector) Name() string

func (Dialector) QuoteTo

func (d Dialector) QuoteTo(writer clause.Writer, str string)

func (Dialector) RewriteLimit

func (d Dialector) RewriteLimit(c clause.Clause, builder clause.Builder)

func (Dialector) RewriteWhere

func (d Dialector) RewriteWhere(c clause.Clause, builder clause.Builder)

func (Dialector) RollbackTo

func (d Dialector) RollbackTo(tx *gorm.DB, name string) error

func (Dialector) SavePoint

func (d Dialector) SavePoint(tx *gorm.DB, name string) error

type Migrator

type Migrator struct {
	migrator.Migrator
}

func (Migrator) AddColumn

func (m Migrator) AddColumn(value interface{}, field string) error

func (Migrator) AlterColumn

func (m Migrator) AlterColumn(value interface{}, field string) error

func (Migrator) AutoMigrate

func (m Migrator) AutoMigrate(values ...interface{}) error

func (Migrator) ColumnTypes

func (m Migrator) ColumnTypes(value interface{}) ([]gorm.ColumnType, error)

func (Migrator) CreateConstraint

func (m Migrator) CreateConstraint(value interface{}, name string) error

func (Migrator) CreateIndex

func (m Migrator) CreateIndex(value interface{}, name string) error

func (Migrator) CreateTable

func (m Migrator) CreateTable(values ...interface{}) error

func (Migrator) CurrentDatabase

func (m Migrator) CurrentDatabase() (name string)

func (Migrator) DropColumn

func (m Migrator) DropColumn(value interface{}, name string) error

func (Migrator) DropConstraint

func (m Migrator) DropConstraint(value interface{}, name string) error

func (Migrator) DropIndex

func (m Migrator) DropIndex(value interface{}, name string) error

func (Migrator) DropTable

func (m Migrator) DropTable(values ...interface{}) error

func (Migrator) HasColumn

func (m Migrator) HasColumn(value interface{}, field string) bool

func (Migrator) HasConstraint

func (m Migrator) HasConstraint(value interface{}, name string) bool

func (Migrator) HasIndex

func (m Migrator) HasIndex(value interface{}, name string) bool

func (Migrator) HasTable

func (m Migrator) HasTable(value interface{}) bool

func (Migrator) RenameIndex

func (m Migrator) RenameIndex(value interface{}, oldName, newName string) error

https://docs.dm.com/database/121/SPATL/alter-index-rename.htm

func (Migrator) RenameTable

func (m Migrator) RenameTable(oldName, newName interface{}) (err error)

func (Migrator) TryQuotifyReservedWords

func (m Migrator) TryQuotifyReservedWords(values ...interface{}) error

func (Migrator) TryRemoveOnUpdate

func (m Migrator) TryRemoveOnUpdate(values ...interface{}) error

type Namer

type Namer struct {
	schema.NamingStrategy
}

func (Namer) CheckerName

func (n Namer) CheckerName(table, column string) (name string)

func (Namer) ColumnName

func (n Namer) ColumnName(table, column string) (name string)

func (Namer) IndexName

func (n Namer) IndexName(table, column string) (name string)

func (Namer) JoinTableName

func (n Namer) JoinTableName(table string) (name string)

func (Namer) RelationshipFKName

func (n Namer) RelationshipFKName(relationship schema.Relationship) (name string)

func (Namer) TableName

func (n Namer) TableName(table string) (name string)

type STable

type STable struct {
	Conn  *gorm.DB
	Table interface{}
}

func Table

func Table(table ...interface{}) *STable

func (*STable) AutoMigrate

func (stb *STable) AutoMigrate(dst ...interface{}) error

func (*STable) ClausesAssignmentColumns

func (stb *STable) ClausesAssignmentColumns(name string, doUpdates []string) error

func (*STable) Create

func (stb *STable) Create() error

func (*STable) DB

func (stb *STable) DB() (*sql.DB, error)

func (*STable) Delete

func (stb *STable) Delete() error

func (*STable) DropTable

func (stb *STable) DropTable(dest ...interface{}) error

func (*STable) Get

func (stb *STable) Get(dest interface{}, conds ...interface{}) error

func (*STable) GetAll

func (stb *STable) GetAll(dest interface{}) error

func (*STable) GetWhere

func (stb *STable) GetWhere(dest interface{}) error

func (*STable) HasTable

func (stb *STable) HasTable(dest interface{}) bool

func (*STable) Model

func (stb *STable) Model() *gorm.DB

func (*STable) Update

func (stb *STable) Update(dest interface{}) error

Directories

Path Synopsis
dmr
* Copyright (c) 2000-2018, 达梦数据库有限公司.
* Copyright (c) 2000-2018, 达梦数据库有限公司.
parser
* Copyright (c) 2000-2018, 达梦数据库有限公司.
* Copyright (c) 2000-2018, 达梦数据库有限公司.
security
This is a mirror of golang.org/x/crypto/internal/subtle.
This is a mirror of golang.org/x/crypto/internal/subtle.
util
* Copyright (c) 2000-2018, 达梦数据库有限公司.
* Copyright (c) 2000-2018, 达梦数据库有限公司.

Jump to

Keyboard shortcuts

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