From efe5281f2f2b1ff51dee5cb1d2daa8aa900bf206 Mon Sep 17 00:00:00 2001 From: DanyLE Date: Tue, 31 Jan 2023 15:17:54 +0100 Subject: [PATCH] fix: generated sql with syntax error when some input object is empty --- silkmvc/core/sqlite.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/silkmvc/core/sqlite.lua b/silkmvc/core/sqlite.lua index c6fc914..3aa4441 100644 --- a/silkmvc/core/sqlite.lua +++ b/silkmvc/core/sqlite.lua @@ -40,22 +40,22 @@ function SQLQueryGenerator:sql_select() return v, f end local segments = {"SELECT"} - if f then + if f and f~= "" then table.insert(segments, f) else table.insert(segments, "*") end table.insert(segments, "FROM") table.insert(segments, self.table_name) - if j then + if j and j~= "" then table.insert(segments, j) end - if w then + if w and j ~="" then table.insert(segments, "WHERE") table.insert(segments, w) end - if o then + if o and o ~= "" then table.insert(segments, "ORDER BY") table.insert(segments, o) end @@ -71,10 +71,10 @@ function SQLQueryGenerator:sql_delete() local segments = {"DELETE"} table.insert(segments, "FROM") table.insert(segments, self.table_name) - if j then + if j and j ~= "" then table.insert(segments, j) end - if w then + if w and w ~= "" then table.insert(segments, "WHERE") table.insert(segments, w) end