     ///     // original row.
     ///     struct FirstColumnAdapter : RowAdapter {
     ///         func concreteRowAdapter(with statement: SelectStatement) throws -> ConcreteRowAdapter {
-    ///             return AdaptedColumnsDescription(columns: [(0, "foo")])
+    ///             return ConcreteColumnMapping(columns: [(0, "foo")])
     ///         }
     ///     }
     ///

    #endif
#endif

/// AdaptedColumnsDescription is a type that supports the RowAdapter protocol.
public struct AdaptedColumnsDescription {
    let columns: [(Int, String)]         // [(baseRowIndex, adaptedColumn), ...]
    let lowercaseColumnIndexes: [String: Int]   // [adaptedColumn: adaptedRowIndex]

    /// Creates an AdaptedColumnsDescription from an array of (index, name)
    /// pairs. In each pair:
    ///
    /// - index is the index of a column in an original row
    /// - name is the name of the column in an adapted row
    ///
    /// For example, the following AdaptedColumnsDescription defines two
    /// columns, "foo" and "bar", that load from the original columns at
    /// indexes 1 and 2:
    ///
    ///     AdaptedColumnsDescription([(1, "foo"), (2, "bar")])
    ///
    /// Use it in your custom RowAdapter type:
    ///
    ///     struct FooBarAdapter : RowAdapter {
    ///         func concreteRowAdapter(with statement: SelectStatement) throws -> ConcreteRowAdapter {
    ///             return AdaptedColumnsDescription([(1, "foo"), (2, "bar")])
    ///         }
    ///     }
    ///
    ///     // <Row foo:2 bar: 3>
    ///     Row.fetchOne(db, "SELECT 1, 2, 3", adapter: FooBarAdapter())
    public init(columns: [(Int, String)]) {
        self.columns = columns
        self.lowercaseColumnIndexes = Dictionary(keyValueSequence: columns.enumerate().map { ($1.1.lowercaseString, $0) }.reverse())

struct AdapterRowImpl : RowImpl {
    let baseRow: Row
    let concreteRowAdapter: ConcreteRowAdapter
    let concreteColumnMapping: ConcreteColumnMapping

    init(baseRow: Row, concreteRowAdapter: ConcreteRowAdapter) {
        self.baseRow = baseRow
        self.concreteRowAdapter = concreteRowAdapter
        self.concreteColumnMapping = concreteRowAdapter.concreteColumnMapping
    }

    var count: Int {
        return concreteColumnMapping.count
    }

    func databaseValue(atIndex index: Int) -> DatabaseValue {
        return baseRow.databaseValue(atIndex: concreteColumnMapping.baseColumIndex(adaptedIndex: index))
    }

    func dataNoCopy(atIndex index:Int) -> NSData? {
        return baseRow.dataNoCopy(atIndex: concreteColumnMapping.baseColumIndex(adaptedIndex: index))
    }

    func columnName(atIndex index: Int) -> String {
        return concreteColumnMapping.columnName(adaptedIndex: index)
    }

    func indexOfColumn(named name: String) -> Int? {
        return concreteColumnMapping.adaptedIndexOfColumn(named: name)
    }

    func scoped(on name: String) -> Row? {
