From 7bc35825258494f4255a23933b801b422fa4dcd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gwendal=20Roue=CC=81?= Date: Sun, 2 Apr 2017 14:18:48 +0200 Subject: [PATCH] SelectStatement.SelectionInfo.description --- GRDB/Core/Statement.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/GRDB/Core/Statement.swift b/GRDB/Core/Statement.swift index fda0b1a51..26730ae41 100644 --- a/GRDB/Core/Statement.swift +++ b/GRDB/Core/Statement.swift @@ -254,7 +254,7 @@ public final class SelectStatement : Statement { } /// Information about the table and columns read by a SelectStatement - public struct SelectionInfo { + public struct SelectionInfo : CustomStringConvertible { mutating func insert(column: String, ofTable table: String) { if selection[table] != nil { selection[table]!.insert(column) @@ -272,6 +272,14 @@ public final class SelectStatement : Statement { } private var selection: [String: Set] = [:] // [TableName: Set] + + /// A textual representation of `self`. + public var description: String { + return selection + .sorted { $0.key < $1.key } + .map { (table, columns) in "\(table)(\(columns.sorted().joined(separator: ", ")))" } + .joined(separator: ", ") + } } }