Skip to content

Commit

Permalink
lua compatibility fixes
Browse files Browse the repository at this point in the history
fixes affected_rows always nil on Lua 5.2+

fixes tests always failing on Lua 5.2+
  • Loading branch information
jprjr authored and leafo committed Nov 23, 2020
1 parent e14ba4c commit ff188f9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pgmoon/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ do
local command, affected_rows
if command_complete then
command = command_complete:match("^%w+")
affected_rows = tonumber(command_complete:match("%d+%z$"))
affected_rows = tonumber(command_complete:match("(%d+)%z$"))
end
if row_desc then
if not (data_rows) then
Expand Down
2 changes: 1 addition & 1 deletion pgmoon/init.moon
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ class Postgres

if command_complete
command = command_complete\match "^%w+"
affected_rows = tonumber command_complete\match "%d+%z$"
affected_rows = tonumber command_complete\match "(%d+)%z$"

if row_desc
return {} unless data_rows
Expand Down
7 changes: 5 additions & 2 deletions spec/pgmoon_spec.moon
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ describe "pgmoon with server", ->
local pg

setup ->
assert 0 == os.execute "dropdb -h '#{HOST}' -p '#{PORT}' --if-exists -U '#{USER}' '#{DB}'"
assert 0 == os.execute "createdb -h '#{HOST}' -p '#{PORT}' -U '#{USER}' '#{DB}'"
r = { os.execute "dropdb -h '#{HOST}' -p '#{PORT}' --if-exists -U '#{USER}' '#{DB}'" }
assert 0 == r[#r]

r = { os.execute "createdb -h '#{HOST}' -p '#{PORT}' -U '#{USER}' '#{DB}'" }
assert 0 == r[#r]

pg = Postgres {
database: DB
Expand Down

0 comments on commit ff188f9

Please sign in to comment.