quoting

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package quoting provides shared identifier quoting utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backtick

func Backtick(s string) string

Backtick quotes a SQL identifier using backticks (MySQL). Internal backticks are escaped by doubling them.

func DoubleQuote

func DoubleQuote(s string) string

DoubleQuote quotes a SQL identifier using double quotes (PostgreSQL, SQLite, ANSI SQL). Internal double quotes are escaped by doubling them.

func EscapeLikePattern

func EscapeLikePattern(s string) string

EscapeLikePattern escapes LIKE wildcard characters (%, _) in a string so they are matched literally. The backslash is used as the escape character.

func EscapeString

func EscapeString(s string) string

EscapeString escapes a string literal for SQL by doubling single quotes and escaping backslashes (for MySQL compatibility).

SECURITY: This escaping is intended for non-parameterized mode only. Production code should use parameterized queries (visitors.WithParams()) for all user-provided values. In particular, MySQL with non-default character sets (GBK, SJIS) may have multi-byte sequences where a trailing byte coincides with backslash or quote; parameterized queries avoid this class of attack entirely.

Types

This section is empty.

Jump to

Keyboard shortcuts

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