mirror of
https://github.com/lxsang/silk.git
synced 2024-11-14 17:28:22 +01:00
fix: generated sql with syntax error when some input object is empty
All checks were successful
gitea-sync/silk/pipeline/head This commit looks good
All checks were successful
gitea-sync/silk/pipeline/head This commit looks good
This commit is contained in:
parent
eae3ae7b14
commit
efe5281f2f
@ -40,22 +40,22 @@ function SQLQueryGenerator:sql_select()
|
|||||||
return v, f
|
return v, f
|
||||||
end
|
end
|
||||||
local segments = {"SELECT"}
|
local segments = {"SELECT"}
|
||||||
if f then
|
if f and f~= "" then
|
||||||
table.insert(segments, f)
|
table.insert(segments, f)
|
||||||
else
|
else
|
||||||
table.insert(segments, "*")
|
table.insert(segments, "*")
|
||||||
end
|
end
|
||||||
table.insert(segments, "FROM")
|
table.insert(segments, "FROM")
|
||||||
table.insert(segments, self.table_name)
|
table.insert(segments, self.table_name)
|
||||||
if j then
|
if j and j~= "" then
|
||||||
table.insert(segments, j)
|
table.insert(segments, j)
|
||||||
end
|
end
|
||||||
if w then
|
if w and j ~="" then
|
||||||
table.insert(segments, "WHERE")
|
table.insert(segments, "WHERE")
|
||||||
table.insert(segments, w)
|
table.insert(segments, w)
|
||||||
end
|
end
|
||||||
|
|
||||||
if o then
|
if o and o ~= "" then
|
||||||
table.insert(segments, "ORDER BY")
|
table.insert(segments, "ORDER BY")
|
||||||
table.insert(segments, o)
|
table.insert(segments, o)
|
||||||
end
|
end
|
||||||
@ -71,10 +71,10 @@ function SQLQueryGenerator:sql_delete()
|
|||||||
local segments = {"DELETE"}
|
local segments = {"DELETE"}
|
||||||
table.insert(segments, "FROM")
|
table.insert(segments, "FROM")
|
||||||
table.insert(segments, self.table_name)
|
table.insert(segments, self.table_name)
|
||||||
if j then
|
if j and j ~= "" then
|
||||||
table.insert(segments, j)
|
table.insert(segments, j)
|
||||||
end
|
end
|
||||||
if w then
|
if w and w ~= "" then
|
||||||
table.insert(segments, "WHERE")
|
table.insert(segments, "WHERE")
|
||||||
table.insert(segments, w)
|
table.insert(segments, w)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user