Skip to content

Commit

Permalink
fix(dao) auto paging queries not throwing errors in prepare step
Browse files Browse the repository at this point in the history
Auto paginated aueries that failed preparation used to not throw an
error if the prepare failed. Thus misleading into confusing error
messages as in Kong#532.
  • Loading branch information
thibaultcha committed Sep 9, 2015
1 parent 46ee668 commit 6f12a41
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions kong/dao/cassandra/base_dao.lua
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,19 @@ function BaseDao:_execute(query, args, options, keyspace)
-- Prepare query and cache the prepared statement for later call
local statement, cache_key, err = self:get_or_prepare_stmt(session, query)
if err then
if options and options.auto_paging then
-- Allow the iteration to run once and thus catch the error
return function() return {}, err end
end
return nil, err
end

if options and options.auto_paging then
local _, rows, page, err = session:execute(statement, args, options)
local _, rows, err, page = session:execute(statement, args, options)
for i, row in ipairs(rows) do
rows[i] = self:_unmarshall(row)
end
return _, rows, page, err
return _, rows, err, page
end

local results, err = session:execute(statement, args, options)
Expand Down

0 comments on commit 6f12a41

Please sign in to comment.