From 69a749a2589a1293114d92d8358574faab9a5cba Mon Sep 17 00:00:00 2001 From: James Friel Date: Wed, 16 Oct 2024 13:15:13 +0100 Subject: [PATCH] add boolean syntax helpers --- FAnsiSql/Discovery/QuerySyntaxHelper.cs | 3 +++ .../MicrosoftSQL/MicrosoftQuerySyntaxHelper.cs | 4 ++++ FAnsiSql/Implementations/MySql/MySqlQuerySyntaxHelper.cs | 4 ++++ FAnsiSql/Implementations/Oracle/OracleQuerySyntaxHelper.cs | 4 ++++ FAnsiSql/Implementations/PostgreSql/PostgreSqlSyntaxHelper.cs | 4 ++++ 5 files changed, 19 insertions(+) diff --git a/FAnsiSql/Discovery/QuerySyntaxHelper.cs b/FAnsiSql/Discovery/QuerySyntaxHelper.cs index 3430fb8f..246deabf 100644 --- a/FAnsiSql/Discovery/QuerySyntaxHelper.cs +++ b/FAnsiSql/Discovery/QuerySyntaxHelper.cs @@ -39,6 +39,9 @@ public abstract partial class QuerySyntaxHelper( /// public virtual char[] IllegalNameChars { get; } = ['.', '(', ')']; + public abstract string False { get; } + public abstract string True { get; } + /// /// Regex for identifying parameters in blocks of SQL (starts with @ or : (Oracle) /// diff --git a/FAnsiSql/Implementations/MicrosoftSQL/MicrosoftQuerySyntaxHelper.cs b/FAnsiSql/Implementations/MicrosoftSQL/MicrosoftQuerySyntaxHelper.cs index 612a6fdf..5d08056e 100644 --- a/FAnsiSql/Implementations/MicrosoftSQL/MicrosoftQuerySyntaxHelper.cs +++ b/FAnsiSql/Implementations/MicrosoftSQL/MicrosoftQuerySyntaxHelper.cs @@ -28,6 +28,10 @@ public sealed class MicrosoftQuerySyntaxHelper : QuerySyntaxHelper public override string CloseQualifier => "]"; + public override string False => "0"; + + public override string True => "1"; + public override TopXResponse HowDoWeAchieveTopX(int x) => new($"TOP {x}", QueryComponent.SELECT); public override string GetParameterDeclaration(string proposedNewParameterName, string sqlType) => $"DECLARE {proposedNewParameterName} AS {sqlType};"; diff --git a/FAnsiSql/Implementations/MySql/MySqlQuerySyntaxHelper.cs b/FAnsiSql/Implementations/MySql/MySqlQuerySyntaxHelper.cs index f2712105..bf89e606 100644 --- a/FAnsiSql/Implementations/MySql/MySqlQuerySyntaxHelper.cs +++ b/FAnsiSql/Implementations/MySql/MySqlQuerySyntaxHelper.cs @@ -21,6 +21,10 @@ public sealed class MySqlQuerySyntaxHelper : QuerySyntaxHelper public override string CloseQualifier => "`"; + public override string False => "0"; + + public override string True => "1"; + private MySqlQuerySyntaxHelper() : base(MySqlTypeTranslater.Instance, MySqlAggregateHelper.Instance,MySqlUpdateHelper.Instance,DatabaseType.MySql)//no specific type translation required { } diff --git a/FAnsiSql/Implementations/Oracle/OracleQuerySyntaxHelper.cs b/FAnsiSql/Implementations/Oracle/OracleQuerySyntaxHelper.cs index 62aaa3d0..81b85388 100644 --- a/FAnsiSql/Implementations/Oracle/OracleQuerySyntaxHelper.cs +++ b/FAnsiSql/Implementations/Oracle/OracleQuerySyntaxHelper.cs @@ -26,6 +26,10 @@ private OracleQuerySyntaxHelper() : base(OracleTypeTranslater.Instance, OracleAg public override char ParameterSymbol => ':'; + public override string False => "0"; + + public override string True => "1"; + [return: NotNullIfNotNull(nameof(s))] public override string? GetRuntimeName(string? s) { diff --git a/FAnsiSql/Implementations/PostgreSql/PostgreSqlSyntaxHelper.cs b/FAnsiSql/Implementations/PostgreSql/PostgreSqlSyntaxHelper.cs index 08de9a9b..720b1264 100644 --- a/FAnsiSql/Implementations/PostgreSql/PostgreSqlSyntaxHelper.cs +++ b/FAnsiSql/Implementations/PostgreSql/PostgreSqlSyntaxHelper.cs @@ -24,6 +24,10 @@ private PostgreSqlSyntaxHelper() : base(PostgreSqlTypeTranslater.Instance, Postg public override string CloseQualifier => "\""; + public override string False => "FALSE"; + + public override string True => "TRUE"; + public override bool SupportsEmbeddedParameters() => false; protected override object FormatDateTimeForDbParameter(DateTime dateTime) =>