refactor(db/pgsql): Revert SQL queries, lower column casing for PGSQL

Reverts SQL query identifier escaping to simplify queries and improves overall readability by using lowercase column names.

Enhances maintainability and alignment with database conventions by adopting a uniform casing scheme across all SQL operations.

Removes unnecessary complexity in query construction, streamlining the database operations performed within the application.
This commit is contained in:
Sakura Akeno Isayeki 2025-05-03 19:20:21 +02:00
parent 4c13084eb3
commit 9c473e35a6
No known key found for this signature in database
GPG key ID: BAB781B71FD2E7E6
8 changed files with 79 additions and 111 deletions

View file

@ -68,7 +68,7 @@ public class PostgresQueryCreator : GenericQueryCreator
dataType = DbTypeToString(c.Type, c.Length);
}
return "\"{0}\" {1} {2} {3} {4}".SFormat(c.Name,
return "{0} {1} {2} {3} {4}".SFormat(c.Name,
dataType,
c.Primary ? "PRIMARY KEY" : "",
c.NotNull && !c.AutoIncrement ? "NOT NULL" : "", // SERIAL implies NOT NULL
@ -76,12 +76,12 @@ public class PostgresQueryCreator : GenericQueryCreator
});
string[] uniques = table.Columns
.Where(c => c.Unique).Select(c => $"\"{c.Name}\"")
.Where(c => c.Unique).Select(c => c.Name)
.ToArray(); // No re-enumeration
return $"CREATE TABLE {EscapeTableName(table.Name)} ({string.Join(", ", columns)} {(uniques.Any() ? ", UNIQUE({0})".SFormat(string.Join(", ", uniques)) : "")})";
}
/// <inheritdoc />
public override string RenameTable(string from, string to) => /*lang=postgresql*/"ALTER TABLE {0} RENAME TO {1}".SFormat(from, to);
public override string RenameTable(string from, string to) => "ALTER TABLE {0} RENAME TO {1}".SFormat(from, to);
}