diff --git a/TShockAPI/DB/Queries/GenericQueryCreator.cs b/TShockAPI/DB/Queries/GenericQueryBuilder.cs similarity index 97% rename from TShockAPI/DB/Queries/GenericQueryCreator.cs rename to TShockAPI/DB/Queries/GenericQueryBuilder.cs index f9fc2038..b62d3925 100644 --- a/TShockAPI/DB/Queries/GenericQueryCreator.cs +++ b/TShockAPI/DB/Queries/GenericQueryBuilder.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011-2019 Pryaxis & TShock Contributors +Copyright (C) 2011-2025 Pryaxis & TShock Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,7 +28,7 @@ namespace TShockAPI.DB.Queries; /// /// A Generic Query Creator (abstract) /// -public abstract class GenericQueryCreator : IQueryBuilder +public abstract class GenericQueryBuilder : IQueryBuilder { protected static Random rand = new Random(); @@ -130,7 +130,7 @@ public abstract class GenericQueryCreator : IQueryBuilder /// /// /// - protected static string BuildWhere(List wheres) => wheres.Count > 0 + protected static string BuildWhere(List wheres) => wheres.Count > 0 ? string.Empty : "WHERE {0}".SFormat(string.Join(", ", wheres.Select(v => $"{v.Name} = {v.Value}"))); } diff --git a/TShockAPI/DB/Queries/IQueryBuilder.cs b/TShockAPI/DB/Queries/IQueryBuilder.cs index dc61370f..fe2d6b53 100644 --- a/TShockAPI/DB/Queries/IQueryBuilder.cs +++ b/TShockAPI/DB/Queries/IQueryBuilder.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011-2019 Pryaxis & TShock Contributors +Copyright (C) 2011-2025 Pryaxis & TShock Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/TShockAPI/DB/Queries/MysqlQueryCreator.cs b/TShockAPI/DB/Queries/MysqlQueryBuilder.cs similarity index 95% rename from TShockAPI/DB/Queries/MysqlQueryCreator.cs rename to TShockAPI/DB/Queries/MysqlQueryBuilder.cs index 1c0ec24f..85185960 100644 --- a/TShockAPI/DB/Queries/MysqlQueryCreator.cs +++ b/TShockAPI/DB/Queries/MysqlQueryBuilder.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011-2019 Pryaxis & TShock Contributors +Copyright (C) 2011-2025 Pryaxis & TShock Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ namespace TShockAPI.DB.Queries; /// /// Query Creator for MySQL /// -public class MysqlQueryCreator : GenericQueryCreator, IQueryBuilder +public class MysqlQueryBuilder : GenericQueryBuilder, IQueryBuilder { /// /// Creates a table from a SqlTable object. diff --git a/TShockAPI/DB/Queries/PostgresQueryCreator.cs b/TShockAPI/DB/Queries/PostgresQueryBuilder.cs similarity index 96% rename from TShockAPI/DB/Queries/PostgresQueryCreator.cs rename to TShockAPI/DB/Queries/PostgresQueryBuilder.cs index c12e2ec8..dd92121e 100644 --- a/TShockAPI/DB/Queries/PostgresQueryCreator.cs +++ b/TShockAPI/DB/Queries/PostgresQueryBuilder.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011-2019 Pryaxis & TShock Contributors +Copyright (C) 2011-2025 Pryaxis & TShock Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ namespace TShockAPI.DB.Queries; /// /// Query Creator for PostgreSQL /// -public class PostgresQueryCreator : GenericQueryCreator +public class PostgresQueryBuilder : GenericQueryBuilder { /// public override string DbTypeToString(MySqlDbType type, int? length) => type switch diff --git a/TShockAPI/DB/Queries/SqliteQueryCreator.cs b/TShockAPI/DB/Queries/SqliteQueryBuilder.cs similarity index 96% rename from TShockAPI/DB/Queries/SqliteQueryCreator.cs rename to TShockAPI/DB/Queries/SqliteQueryBuilder.cs index 229ba49b..72de17d5 100644 --- a/TShockAPI/DB/Queries/SqliteQueryCreator.cs +++ b/TShockAPI/DB/Queries/SqliteQueryBuilder.cs @@ -1,6 +1,6 @@ /* TShock, a server mod for Terraria -Copyright (C) 2011-2019 Pryaxis & TShock Contributors +Copyright (C) 2011-2025 Pryaxis & TShock Contributors This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ namespace TShockAPI.DB.Queries; /// /// Query Creator for Sqlite /// -public class SqliteQueryCreator : GenericQueryCreator, IQueryBuilder +public class SqliteQueryBuilder : GenericQueryBuilder, IQueryBuilder { /// /// Creates a table from a SqlTable object. diff --git a/TShockAPI/Extensions/DbExt.cs b/TShockAPI/Extensions/DbExt.cs index ba2cfd1f..efbf68b7 100644 --- a/TShockAPI/Extensions/DbExt.cs +++ b/TShockAPI/Extensions/DbExt.cs @@ -158,9 +158,9 @@ namespace TShockAPI.DB public static IQueryBuilder GetSqlQueryBuilder(this IDbConnection db) => db.GetSqlType() switch { - SqlType.Sqlite => new SqliteQueryCreator(), - SqlType.Mysql => new MysqlQueryCreator(), - SqlType.Postgres => new PostgresQueryCreator(), + SqlType.Sqlite => new SqliteQueryBuilder(), + SqlType.Mysql => new MysqlQueryBuilder(), + SqlType.Postgres => new PostgresQueryBuilder(), _ => throw new NotSupportedException("Database type not supported.") };