Skip to content

Commit

Permalink
Merge pull request Kong#1269 from Mashape/bugfix/failed_error_parsing
Browse files Browse the repository at this point in the history
Fixed a failed error parsing on Postgres.
  • Loading branch information
subnetmarco committed May 31, 2016
2 parents 0be3ee9 + c069ff4 commit 95e24c2
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions kong/dao/postgres_db.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,17 @@ local function parse_error(err_str)
local err
if string.find(err_str, "Key .* already exists") then
local col, value = string.match(err_str, "%((.+)%)=%((.+)%)")
err = Errors.unique {[col] = value}
if col then
err = Errors.unique {[col] = value}
end
elseif string.find(err_str, "violates foreign key constraint") then
local col, value = string.match(err_str, "%((.+)%)=%((.+)%)")
err = Errors.foreign {[col] = value}
else
err = Errors.db(err_str)
if col then
err = Errors.foreign {[col] = value}
end
end

return err
return err or Errors.db(err_str)
end

local function get_select_fields(schema)
Expand Down

0 comments on commit 95e24c2

Please sign in to comment.