Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var Debug bool
Debug flag for enabling debug mode
Functions ¶
func RegisterFactory ¶
func RegisterFactory(driver string, factory SQLFactory)
RegisterFactory registers a SQL factory for a specific driver
func UnregisterFactory ¶
func UnregisterFactory(driver string)
UnregisterFactory removes a SQL factory for a specific driver
Types ¶
type ColumnInfo ¶
type ColumnInfo struct {
Name string // 列名
Type string // 数据库类型
Length int64 // 长度
Precision int // 精度
Scale int // 小数位数
IsNullable bool // 是否可空
IsPrimaryKey bool // 是否主键
IsAutoIncrement bool // 是否自增
DefaultValue string // 默认值
Comment string // 注释
}
ColumnInfo 列信息
type ITableModel ¶
type ITableModel interface {
// TableName returns the custom table name
TableName() string
// CreateSql returns the custom CREATE TABLE SQL statement
CreateSql() string
}
ITableModel defines the interface for custom table models
type Result ¶
Result implements sql.Result interface
func (*Result) LastInsertId ¶
LastInsertId returns the last inserted ID
func (*Result) RowsAffected ¶
RowsAffected returns the number of rows affected
type SQLFactory ¶
type SQLFactory interface {
// Connect creates a new database connection
Connect(dsn string) (*sql.DB, error)
// BuildSelect builds a SELECT query
BuildSelect(table string, fields []string, conditions []*Condition, orderBy string, limit, offset int) (string, []interface{})
// BuildUpdate builds an UPDATE query
BuildUpdate(table string, fields map[string]interface{}, conditions []*Condition) (string, []interface{})
// BuildInsert builds an INSERT query
BuildInsert(table string, fields map[string]interface{}) (string, []interface{})
// BuildBatchInsert builds a batch INSERT query
BuildBatchInsert(table string, values []map[string]interface{}) (string, []interface{})
// BuildDelete builds a DELETE query
BuildDelete(table string, conditions []*Condition) (string, []interface{})
// BuildCreateTable builds a CREATE TABLE query
BuildCreateTable(table string, modelType reflect.Type) string
// GetTableInfo 获取表信息
GetTableInfo(db *sql.DB, tableName string) (*TableInfo, error)
// GetTables 获取符合模式的所有表
// pattern: 表名匹配模式,支持 * 通配符
// 对于 PostgreSQL,pattern 可以是 schema.table 格式
GetTables(db *sql.DB, pattern string) ([]string, error)
}
SQLFactory defines the interface for SQL generation
func GetFactory ¶
func GetFactory(driver string) (SQLFactory, error)
GetFactory returns the SQL factory for a specific driver
Click to show internal directories.
Click to hide internal directories.