Documentation
¶
Overview ¶
Package named2qm 提供了对 SQL 命名参数解析为 ? 占位符 SQL 的支持(用于:MySQL、SQLite 等使用 ? 占位符的驱动)。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ParsedResult ¶
type ParsedResult struct {
Sql string // 处理后的 SQL 语句。
Names []string // 原语句中用到的命名参数集合(没有去重逻辑,如果有同名参数,会有多项)。
}
是 SQL 命名参数解析后的结果。
func ParseNamedSqlToQuestionMark ¶
func ParseNamedSqlToQuestionMark(sqlText string) ParsedResult
分析 SQL 语句,提取用到的命名参数名称(按顺序),并将 @ 占位参数转换为驱动支持的 ? 形式。 结果会被缓存以提升重复调用性能;无命名参数的 SQL 不写入缓存,以防止动态拼接语句导致内存无限增长。
type QuestionMarkSqlBinder ¶
type QuestionMarkSqlBinder struct {
// contains filtered or unexported fields
}
QuestionMarkSqlBinder 是支持 ? 占位符驱动的命名参数绑定器。
func NewQuestionMarkSqlBinder ¶
func NewQuestionMarkSqlBinder(cacheCapacity int) (*QuestionMarkSqlBinder, error)
NewQuestionMarkSqlBinder 用于创建一个带有独立缓存的绑定器。
func (*QuestionMarkSqlBinder) BindQuestionMarkArgs ¶
func (binder *QuestionMarkSqlBinder) BindQuestionMarkArgs(sqlText string, args ...any) (string, []any, error)
BindQuestionMarkArgs 对使用 ? 占位符的驱动(如 MySQL、SQLite)做参数预处理。 若唯一参数为 map,则按 SQL 中的 @name 顺序绑定;否则按 @p1、@p2 形式从 args 切片取位置参数。
func (*QuestionMarkSqlBinder) ParseNamedSqlToQuestionMark ¶
func (binder *QuestionMarkSqlBinder) ParseNamedSqlToQuestionMark(sqlText string) ParsedResult
ParseNamedSqlToQuestionMark 分析 SQL 语句,提取用到的命名参数名称(按顺序),并将 @ 占位参数转换为驱动支持的 ? 形式。 结果会被缓存以提升重复调用性能;无命名参数的 SQL 不写入缓存,以防止动态拼接语句导致内存无限增长。
Click to show internal directories.
Click to hide internal directories.