package schema

type QueryAppender interface {
	AppendQuery(fmter Formatter, b []byte) ([]byte, error)
}

type Query interface {
	QueryAppender
	Operation() string
}

type ColumnsAppender interface {
	AppendColumns(fmter Formatter, b []byte) ([]byte, error)
}

//------------------------------------------------------------------------------

// Safe represents a safe SQL query.
type Safe string

var _ QueryAppender = (*Safe)(nil)

func ( Safe) ( Formatter,  []byte) ([]byte, error) {
	return append(, ...), nil
}

//------------------------------------------------------------------------------

// Ident represents a SQL identifier, for example, table or column name.
type Ident string

var _ QueryAppender = (*Ident)(nil)

func ( Ident) ( Formatter,  []byte) ([]byte, error) {
	return .AppendIdent(, string()), nil
}

//------------------------------------------------------------------------------

type QueryWithArgs struct {
	Query string
	Args  []interface{}
}

var _ QueryAppender = QueryWithArgs{}

func ( string,  []interface{}) QueryWithArgs {
	if  == nil {
		 = make([]interface{}, 0)
	}
	return QueryWithArgs{Query: , Args: }
}

func ( string) QueryWithArgs {
	return QueryWithArgs{Query: }
}

func ( QueryWithArgs) () bool {
	return .Query == "" && .Args == nil
}

func ( QueryWithArgs) ( Formatter,  []byte) ([]byte, error) {
	if .Args == nil {
		return .AppendIdent(, .Query), nil
	}
	return .AppendQuery(, .Query, .Args...), nil
}

//------------------------------------------------------------------------------

type QueryWithSep struct {
	QueryWithArgs
	Sep string
}

func ( string,  []interface{},  string) QueryWithSep {
	return QueryWithSep{
		QueryWithArgs: SafeQuery(, ),
		Sep:           ,
	}
}