     deleteOne: () -> @doOne(@_delete, arguments, 'delete')
 
     _delete: (predicate, cb) ->
-        s = sql.delete(@sqlAlias(), predicate)
+        s = sql.delete(@sqlAlias, predicate)
         return @db.bindOrCall(s, 'noData', cb)
 
     doOne: (fn, args, opName, queryArgument) ->

        @_update(keyValues, cb, updateValues)

    _update: (predicate, cb, values) ->
        s = sql.update(@sqlAlias(), values, predicate)
        return @db.bindOrCall(s, 'noData', cb)

    deleteMany: (predicate, cb) ->
        s = sql.delete(@sqlAlias()).where(predicate)
        return @db.bindOrCall(s, 'noData', cb)

    count: (cb = null) ->

        q = @newQuery()
        return @db.bindOrCall(q, 'allObjects', cb)

    newQuery: () -> sql.from(@sqlAlias).select(sql.star(@sqlAlias))

    merge: (data, cb) ->
        F.demandArray(data, 'data')
        cb(null) if _.isEmpty(data)

        s = sql.merge(@sqlAlias).using(data)
        return @db.bindOrCall(s, 'noData', cb)

    bindError: (msg, cb) ->
        return cb(msg) if cb?
        return queryBinder.bindError(@, msg)

Object.defineProperty(TableGateway::, "sqlAlias", {
    get: () -> @schema.many
})
    
module.exports = TableGateway
