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:
82
internal/core/analysis.go
Normal file
82
internal/core/analysis.go
Normal file
@@ -0,0 +1,82 @@
|
||||
package core
|
||||
|
||||
type Command string
|
||||
|
||||
const (
|
||||
CommandSelect Command = "SELECT"
|
||||
CommandInsert Command = "INSERT"
|
||||
CommandUpdate Command = "UPDATE"
|
||||
CommandDelete Command = "DELETE"
|
||||
)
|
||||
|
||||
type PrepareResult struct {
|
||||
Command Command `json:"command,omitempty"`
|
||||
Columns []Column `json:"columns"`
|
||||
Parameters []Parameter `json:"parameters"`
|
||||
Stars []StarExpansion `json:"stars,omitempty"`
|
||||
}
|
||||
|
||||
// StarExpansion is what a star in a target list stands for. The analyzer
|
||||
// resolves the reference against the query's scope and reports the columns it
|
||||
// covers; rewriting the query text with them is the caller's to do, since only
|
||||
// it knows how the engine quotes an identifier.
|
||||
type StarExpansion struct {
|
||||
// Location is where the target the star belongs to starts, measured the
|
||||
// way the AST measures a node: from the beginning of the file the
|
||||
// statement was parsed from.
|
||||
Location int `json:"location"`
|
||||
|
||||
// Fields is the reference as it was written, with the star as its last
|
||||
// element: ["*"] for a bare star and ["foo", "*"] for a qualified one.
|
||||
Fields []string `json:"fields"`
|
||||
|
||||
// Alias is the output name the target was given, if any.
|
||||
Alias string `json:"alias,omitempty"`
|
||||
|
||||
Columns []StarColumn `json:"columns"`
|
||||
}
|
||||
|
||||
// StarColumn is a single column a star expanded to.
|
||||
type StarColumn struct {
|
||||
// Relation is the name the column's relation goes by in the query, which
|
||||
// is its alias when it was given one.
|
||||
Relation string `json:"relation,omitempty"`
|
||||
Name string `json:"name"`
|
||||
DataType string `json:"data_type,omitempty"`
|
||||
}
|
||||
|
||||
type ColumnSource struct {
|
||||
Schema string `json:"schema,omitempty"`
|
||||
Table string `json:"table,omitempty"`
|
||||
TableAlias string `json:"table_alias,omitempty"`
|
||||
Column string `json:"column,omitempty"`
|
||||
}
|
||||
|
||||
type Column struct {
|
||||
Name string `json:"name"`
|
||||
DataType string `json:"data_type"`
|
||||
// Type is the column's type as an expression, carrying what DataType
|
||||
// and IsArray flatten away: arguments, nesting and inner nullability.
|
||||
Type *TypeExpr `json:"type,omitempty"`
|
||||
TypeOID int64 `json:"type_oid,omitempty"`
|
||||
NotNull bool `json:"not_null"`
|
||||
IsArray bool `json:"is_array,omitempty"`
|
||||
SourceClassOID int64 `json:"source_class_oid,omitempty"`
|
||||
SourceAttributeOID int64 `json:"source_attribute_oid,omitempty"`
|
||||
Source *ColumnSource `json:"source,omitempty"`
|
||||
DeclType string `json:"decl_type,omitempty"`
|
||||
IsPrimaryKey bool `json:"is_primary_key,omitempty"`
|
||||
IsUnique bool `json:"is_unique,omitempty"`
|
||||
IsAutoIncrement bool `json:"is_auto_increment,omitempty"`
|
||||
}
|
||||
|
||||
type Parameter struct {
|
||||
Number int `json:"number"`
|
||||
Name string `json:"name,omitempty"`
|
||||
DataType string `json:"data_type,omitempty"`
|
||||
Type *TypeExpr `json:"type,omitempty"`
|
||||
TypeOID int64 `json:"type_oid,omitempty"`
|
||||
NotNull bool `json:"not_null"`
|
||||
IsArray bool `json:"is_array,omitempty"`
|
||||
Source *ColumnSource `json:"source,omitempty"`
|
||||
}
|
||||
Reference in New Issue
Block a user