Premiere commit - Omika
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
namespace Omika.HfSqlProbe;
|
||||
|
||||
internal static class ProbeSqlBuilder
|
||||
{
|
||||
/// <summary>
|
||||
/// Builds INSERT ... RETURNING <idColumn>.
|
||||
/// Defensively validates all identifiers before interpolation.
|
||||
/// </summary>
|
||||
public static string BuildInsertReturning(string table, string idColumn, string markerColumn)
|
||||
{
|
||||
SqlIdentifierValidator.Validate(table);
|
||||
SqlIdentifierValidator.Validate(idColumn);
|
||||
SqlIdentifierValidator.Validate(markerColumn);
|
||||
return $"INSERT INTO {table} ({markerColumn}) VALUES (?) RETURNING {idColumn}";
|
||||
}
|
||||
|
||||
/// <summary>Count rows matching a marker value.</summary>
|
||||
public static string BuildCountByMarker(string table, string markerColumn)
|
||||
{
|
||||
SqlIdentifierValidator.Validate(table);
|
||||
SqlIdentifierValidator.Validate(markerColumn);
|
||||
return $"SELECT COUNT(*) FROM {table} WHERE {markerColumn} = ?";
|
||||
}
|
||||
|
||||
/// <summary>Insert a marker row (no RETURNING).</summary>
|
||||
public static string BuildInsertMarker(string table, string markerColumn)
|
||||
{
|
||||
SqlIdentifierValidator.Validate(table);
|
||||
SqlIdentifierValidator.Validate(markerColumn);
|
||||
return $"INSERT INTO {table} ({markerColumn}) VALUES (?)";
|
||||
}
|
||||
|
||||
/// <summary>Read GUID samples.</summary>
|
||||
public static string BuildSelectGuids(int limit)
|
||||
{
|
||||
return "SELECT GUID FROM Client WHERE GUID IS NOT NULL AND GUID <> '' " +
|
||||
$"LIMIT {limit}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user