Add ROW constructor and IN/EXISTS operator.

This commit is contained in:
zer0sub 2019-05-05 18:03:30 +02:00
parent 08e4392278
commit 3367df247c
18 changed files with 183 additions and 565 deletions

View file

@ -74,7 +74,7 @@ func (c *baseColumn) setTableName(table string) {
}
func (c *baseColumn) DefaultAlias() Projection {
return c.As(c.tableName + "." + c.name)
return c.AS(c.tableName + "." + c.name)
}
func (c baseColumn) Serialize(out *queryData, options ...serializeOption) error {
@ -102,95 +102,9 @@ func (c baseColumn) Serialize(out *queryData, options ...serializeOption) error
out.WriteString(`"`)
}
//if contains(options, FOR_PROJECTION) && !contains(options, SKIP_DEFAULT_ALIASING) && c.tableName != "" {
// out.WriteString(" AS \"" + c.tableName + "." + c.name + `"`)
//}
if setOrderBy {
out.WriteString(`"`)
}
return nil
}
//
//// This is a strict subset of the actual allowed identifiers
//var validIdentifierRegexp = regexp.MustCompile("^[a-zA-Z_]\\w*$")
//
//// Returns true if the given string is suitable as an identifier.
//func validIdentifierName(name string) bool {
// return validIdentifierRegexp.MatchString(name)
//}
//
//// Pseudo Column type returned by tableName.C(name)
//type deferredLookupColumn struct {
// isProjection
// isExpression
// tableName *Table
// colName string
//
// cachedColumn NonAliasColumn
//}
//
//func (c *deferredLookupColumn) Name() string {
// return c.colName
//}
//
//func (c *deferredLookupColumn) SerializeSqlForColumnList(
// out *bytes.Buffer) error {
//
// return c.Serialize(out)
//}
//
//func (c *deferredLookupColumn) Serialize(out *bytes.Buffer) error {
// if c.cachedColumn != nil {
// return c.cachedColumn.Serialize(out)
// }
//
// col, err := c.tableName.getColumn(c.colName)
// if err != nil {
// return err
// }
//
// c.cachedColumn = col
// return col.Serialize(out)
//}
//
//func (c *deferredLookupColumn) setTableName(tableName string) error {
// return errors.Newf(
// "Lookup column '%s' should never have setTableName called on it",
// c.colName)
//}
//
//func (c *deferredLookupColumn) Eq(rhs Expression) BoolExpression {
// lit, ok := rhs.(*literalExpression)
// if ok && sqltypes.Value(lit.value).IsNull() {
// return newBoolExpression(c, rhs, []byte(" IS "))
// }
// return newBoolExpression(c, rhs, []byte(" = "))
//}
//
//func (c *deferredLookupColumn) Gte(rhs Expression) BoolExpression {
// return Gte(c, rhs)
//}
//
//func (c *deferredLookupColumn) GteLiteral(rhs interface{}) BoolExpression {
// return Gte(c, Literal(rhs))
//}
//
//func (c *deferredLookupColumn) Lte(rhs Expression) BoolExpression {
// return Lte(c, rhs)
//}
//
//func (c *deferredLookupColumn) LteLiteral(literal interface{}) BoolExpression {
// return Lte(c, Literal(literal))
//}
//
//func (c *deferredLookupColumn) Asc() OrderByClause {
// return sqlbuilder.Asc(c)
//}
//
//func (c *deferredLookupColumn) Desc() OrderByClause {
// return sqlbuilder.Desc(c)
//}