snapshot of https://github.com/sqlc-dev/sqlc.git (main, 2026-09-16; blobs > 131072B omitted)
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
Some checks failed
kotlin / test (push) Has been skipped
python / test (push) Has been skipped
typescript / test (push) Has been skipped
go / build darwin/amd64 (push) Has been cancelled
go / build linux/amd64 (push) Has been cancelled
go / build windows/amd64 (push) Has been cancelled
go / build darwin/arm64 (push) Has been cancelled
go / build linux/arm64 (push) Has been cancelled
go / build windows/arm64 (push) Has been cancelled
go / test (push) Has been cancelled
go / vuln_check (push) Has been cancelled
This commit is contained in:
59
internal/engine/clickhouse/utils.go
Normal file
59
internal/engine/clickhouse/utils.go
Normal file
@@ -0,0 +1,59 @@
|
||||
package clickhouse
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
chast "github.com/sqlc-dev/doubleclick/ast"
|
||||
|
||||
"github.com/sqlc-dev/sqlc/internal/debug"
|
||||
"github.com/sqlc-dev/sqlc/internal/sql/ast"
|
||||
)
|
||||
|
||||
func todo(n chast.Node) *ast.TODO {
|
||||
if debug.Active {
|
||||
log.Printf("clickhouse.convert: Unknown node type %T\n", n)
|
||||
}
|
||||
return &ast.TODO{}
|
||||
}
|
||||
|
||||
func identifier(id string) string {
|
||||
return strings.ToLower(id)
|
||||
}
|
||||
|
||||
func NewIdentifier(t string) *ast.String {
|
||||
return &ast.String{Str: identifier(t)}
|
||||
}
|
||||
|
||||
func parseTableName(n *chast.TableIdentifier) *ast.TableName {
|
||||
return &ast.TableName{
|
||||
Schema: identifier(n.Database),
|
||||
Name: identifier(n.Table),
|
||||
}
|
||||
}
|
||||
|
||||
func parseTableIdentifierToRangeVar(n *chast.TableIdentifier) *ast.RangeVar {
|
||||
schemaname := identifier(n.Database)
|
||||
relname := identifier(n.Table)
|
||||
return &ast.RangeVar{
|
||||
Schemaname: &schemaname,
|
||||
Relname: &relname,
|
||||
}
|
||||
}
|
||||
|
||||
func isNotNull(n *chast.ColumnDeclaration) bool {
|
||||
if n.Type == nil {
|
||||
return false
|
||||
}
|
||||
// Check if type is wrapped in Nullable()
|
||||
// If it's Nullable, it can be null, so return false
|
||||
// If it's not Nullable, it's NOT NULL by default in ClickHouse
|
||||
if n.Type.Name != "" && strings.ToLower(n.Type.Name) == "nullable" {
|
||||
return false
|
||||
}
|
||||
// Also check if Nullable field is explicitly set
|
||||
if n.Nullable != nil && *n.Nullable {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
Reference in New Issue
Block a user