Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Super Type Demonstration #304

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 35 additions & 10 deletions go/vt/sqlparser/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -2612,6 +2612,9 @@ type ColumnType struct {
// The base type string
Type string

// The base type if it has already been resolved
ResolvedType any

// Generic field options.
Null BoolVal
NotNull BoolVal
Expand Down Expand Up @@ -2758,17 +2761,19 @@ func (ct *ColumnType) merge(other ColumnType) error {

// Format returns a canonical string representation of the type and all relevant options
func (ct *ColumnType) Format(buf *TrackedBuffer) {
buf.Myprintf("%s", ct.Type)

if ct.Length != nil && ct.Scale != nil {
buf.Myprintf("(%v,%v)", ct.Length, ct.Scale)

} else if ct.Length != nil {
buf.Myprintf("(%v)", ct.Length)
}
if stringer, ok := ct.ResolvedType.(fmt.Stringer); ok {
buf.WriteString(stringer.String())
} else {
buf.Myprintf("%s", ct.Type)
if ct.Length != nil && ct.Scale != nil {
buf.Myprintf("(%v,%v)", ct.Length, ct.Scale)

if len(ct.EnumValues) > 0 {
buf.Myprintf("('%s')", strings.Join(ct.EnumValues, "', '"))
} else if ct.Length != nil {
buf.Myprintf("(%v)", ct.Length)
}
if len(ct.EnumValues) > 0 {
buf.Myprintf("('%s')", strings.Join(ct.EnumValues, "', '"))
}
}

opts := make([]string, 0, 16)
Expand Down Expand Up @@ -7211,3 +7216,23 @@ func (node *SrsAttribute) Format(buf *TrackedBuffer) {
buf.Myprintf("organization '%s' identified by %v\n", node.Organization, node.OrgID)
buf.Myprintf("description '%s'", node.Description)
}

type DoltgresInjectedExpr struct {
Expression any
}

var _ Expr = DoltgresInjectedExpr{}

func (d DoltgresInjectedExpr) iExpr() {}

func (d DoltgresInjectedExpr) replace(from, to Expr) bool {
return false
}

func (d DoltgresInjectedExpr) Format(buf *TrackedBuffer) {
if stringer, ok := d.Expression.(fmt.Stringer); ok {
buf.WriteString(stringer.String())
} else {
buf.WriteString("DoltgresInjectedExpr")
}
}