add query.StringLine

This commit is contained in:
Aneurin Barker Snook
2023-10-13 08:07:06 +01:00
parent 6f85786542
commit c9ce05f9d2
+7
View File
@@ -77,10 +77,17 @@ func (query *Query) Copy() *Query {
return newQuery return newQuery
} }
// String returns the query formatted across multiple lines.
func (query *Query) String() string { func (query *Query) String() string {
return strings.Join(query.Lines, "\n") return strings.Join(query.Lines, "\n")
} }
// StringLine returns the query formatted on a single line.
// This reduces readability but may be more suitable for logging.
func (query *Query) StringLine() string {
return strings.Join(query.Lines, " ")
}
// NewQuery creates a new, empty Query. // NewQuery creates a new, empty Query.
func NewQuery() *Query { func NewQuery() *Query {
return &Query{ return &Query{