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
48 lines
1.0 KiB
Go
48 lines
1.0 KiB
Go
package duckdb
|
|
|
|
import (
|
|
"log"
|
|
"strings"
|
|
|
|
dw "github.com/sqlc-dev/darkwing/ast"
|
|
|
|
"github.com/sqlc-dev/sqlc/internal/debug"
|
|
"github.com/sqlc-dev/sqlc/internal/sql/ast"
|
|
)
|
|
|
|
func todo(n dw.Node) *ast.TODO {
|
|
if debug.Active {
|
|
log.Printf("duckdb.convert: Unknown node type %T\n", n)
|
|
}
|
|
return &ast.TODO{}
|
|
}
|
|
|
|
// identifier normalizes an identifier. DuckDB identifiers are
|
|
// case-insensitive (though case-preserving); the catalog matches them
|
|
// lowercased.
|
|
func identifier(id string) string {
|
|
return strings.ToLower(id)
|
|
}
|
|
|
|
func NewIdentifier(t string) *ast.String {
|
|
return &ast.String{Str: identifier(t)}
|
|
}
|
|
|
|
// schemaName normalizes a schema qualifier. DuckDB's default "main" schema
|
|
// maps to the catalog's default namespace, so it is treated as unqualified.
|
|
func schemaName(s string) string {
|
|
s = identifier(s)
|
|
if s == "main" {
|
|
return ""
|
|
}
|
|
return s
|
|
}
|
|
|
|
func parseTableName(catalog, schema, name string) *ast.TableName {
|
|
return &ast.TableName{
|
|
Catalog: identifier(catalog),
|
|
Schema: schemaName(schema),
|
|
Name: identifier(name),
|
|
}
|
|
}
|