/
githubmirror
/
sqlc
Обзор
Документация
Войти
/
githubmirror
/
sqlc
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
internal/engine/clickhouse/format.go
35 строк
1 KB
Kyle Gray
feat: add ClickHouse support to `sqlc parse` (#4267)
30 янв 2026, 08:39
Не верифицирован
30 янв 2026, 08:39
16c9afd
Код
Авторство
О чём код?
package clickhouse // QuoteIdent returns a quoted identifier if it needs quoting. // ClickHouse uses backticks or double quotes for quoting identifiers. func (p *Parser) QuoteIdent(s string) string { // For now, don't quote - can be extended to quote when necessary return s } // TypeName returns the SQL type name for the given namespace and name. func (p *Parser) TypeName(ns, name string) string { if ns != "" { return ns + "." + name } return name } // Param returns the parameter placeholder for the given number. // ClickHouse uses {name:Type} for named parameters, but for positional // parameters we use ? which is supported by the clickhouse-go driver. func (p *Parser) Param(n int) string { return "?" } // NamedParam returns the named parameter placeholder for the given name. // ClickHouse uses {name:Type} syntax for named parameters. func (p *Parser) NamedParam(name string) string { return "{" + name + ":String}" } // Cast returns a type cast expression. // ClickHouse uses CAST(expr AS type) syntax, same as MySQL. func (p *Parser) Cast(arg, typeName string) string { return "CAST(" + arg + " AS " + typeName + ")" }