Diff

plugins/mod_storage_sql.lua @ 13780:40185fad7505 13.0

mod_storage_sql: Fix indentation Off-by-one in autoindent after `if not success then` since 3ec48555b773
author Kim Alvefur <zash@zash.se>
date Wed, 19 Mar 2025 16:13:32 +0100
parent 13661:5a7f042fe05d
child 13784:b30eaa74d35b
line wrap: on
line diff
--- a/plugins/mod_storage_sql.lua	Mon Mar 17 16:48:39 2025 +0000
+++ b/plugins/mod_storage_sql.lua	Wed Mar 19 16:13:32 2025 +0100
@@ -866,38 +866,38 @@
 		success,err = engine:transaction(function()
 			return engine:execute(check_encoding_query, params.database,
 				engine.charset, engine.charset.."_bin");
-			end);
-			if not success then
-				module:log("error", "Failed to check/upgrade database encoding: %s", err or "unknown error");
-				return false;
-			end
-		else
-			local indices = {};
-			engine:transaction(function ()
-				if params.driver == "SQLite3" then
-					for row in engine:select [[SELECT "name" FROM "sqlite_schema" WHERE "type"='index' AND "tbl_name"='prosody' AND "name"='prosody_index';]] do
-						indices[row[1]] = true;
-					end
-				elseif params.driver == "PostgreSQL" then
-					for row in engine:select [[SELECT "indexname" FROM "pg_indexes" WHERE "tablename"='prosody' AND "indexname"='prosody_index';]] do
-						indices[row[1]] = true;
-					end
+		end);
+		if not success then
+			module:log("error", "Failed to check/upgrade database encoding: %s", err or "unknown error");
+			return false;
+		end
+	else
+		local indices = {};
+		engine:transaction(function ()
+			if params.driver == "SQLite3" then
+				for row in engine:select [[SELECT "name" FROM "sqlite_schema" WHERE "type"='index' AND "tbl_name"='prosody' AND "name"='prosody_index';]] do
+					indices[row[1]] = true;
 				end
-			end)
-			if indices["prosody_index"] then
-				if apply_changes then
-					local success = engine:transaction(function ()
-						return assert(engine:execute([[DROP INDEX "prosody_index";]]));
-					end);
-					if not success then
-						module:log("error", "Failed to delete obsolete index \"prosody_index\"");
-						return false;
-					end
-				else
-					changes = true;
+			elseif params.driver == "PostgreSQL" then
+				for row in engine:select [[SELECT "indexname" FROM "pg_indexes" WHERE "tablename"='prosody' AND "indexname"='prosody_index';]] do
+					indices[row[1]] = true;
 				end
 			end
+		end)
+		if indices["prosody_index"] then
+			if apply_changes then
+				local success = engine:transaction(function ()
+					return assert(engine:execute([[DROP INDEX "prosody_index";]]));
+				end);
+				if not success then
+					module:log("error", "Failed to delete obsolete index \"prosody_index\"");
+					return false;
+				end
+			else
+				changes = true;
+			end
 		end
+	end
 	return changes;
 end