refactor: Rename query builder classes for consistency

Standardizes class names for different database query builders, aligning naming conventions across SQLite, MySQL, PostgreSQL implementations, and updating related factory method calls to improve code clarity and maintainability.
This commit is contained in:
Sakura Akeno Isayeki 2025-05-10 15:28:56 +02:00
parent 22a3f77271
commit f5c1bf24c0
No known key found for this signature in database
GPG key ID: BAB781B71FD2E7E6
6 changed files with 13 additions and 13 deletions

View file

@ -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;
/// <summary>
/// A Generic Query Creator (abstract)
/// </summary>
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
/// </summary>
/// <param name="wheres"></param>
/// <returns></returns>
protected static string BuildWhere(List<SqlValue> wheres) => wheres.Count > 0
protected static string BuildWhere(List<SqlValue> wheres) => wheres.Count > 0
? string.Empty
: "WHERE {0}".SFormat(string.Join(", ", wheres.Select(v => $"{v.Name} = {v.Value}")));
}

View file

@ -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

View file

@ -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;
/// <summary>
/// Query Creator for MySQL
/// </summary>
public class MysqlQueryCreator : GenericQueryCreator, IQueryBuilder
public class MysqlQueryBuilder : GenericQueryBuilder, IQueryBuilder
{
/// <summary>
/// Creates a table from a SqlTable object.

View file

@ -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;
/// <summary>
/// Query Creator for PostgreSQL
/// </summary>
public class PostgresQueryCreator : GenericQueryCreator
public class PostgresQueryBuilder : GenericQueryBuilder
{
/// <inheritdoc />
public override string DbTypeToString(MySqlDbType type, int? length) => type switch

View file

@ -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;
/// <summary>
/// Query Creator for Sqlite
/// </summary>
public class SqliteQueryCreator : GenericQueryCreator, IQueryBuilder
public class SqliteQueryBuilder : GenericQueryBuilder, IQueryBuilder
{
/// <summary>
/// Creates a table from a SqlTable object.

View file

@ -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.")
};