diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index a56452ddf2bc..a8413050b378 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -153,6 +153,10 @@ changes (where available). - Check added to ensure view has changed before processing GUI events preventing hang on start. +- return an empty table (nil) for a non-existent tag accessed by index + +- return an empty table (nil) when a tag contains no images with the tag + ### Add action support for Lua ### Other Lua changes diff --git a/src/lua/tags.c b/src/lua/tags.c index d2e4259e10c8..e810e1a0727b 100644 --- a/src/lua/tags.c +++ b/src/lua/tags.c @@ -92,7 +92,8 @@ static int tag_index(lua_State *L) int index = luaL_checkinteger(L, -1); if(index < 1) { - return luaL_error(L, "incorrect index in database"); + lua_pushnil(L); + return 1; } sqlite3_stmt *stmt = NULL; char query[1024]; @@ -107,8 +108,7 @@ static int tag_index(lua_State *L) } else { - sqlite3_finalize(stmt); - luaL_error(L, "incorrect index in database"); + lua_pushnil(L); } sqlite3_finalize(stmt); return 1;