From 96c57ebce3372acc86bb147b012cb9ccc890ebe3 Mon Sep 17 00:00:00 2001 From: Michael Camara Pendon Date: Thu, 2 Dec 2021 00:20:05 +0100 Subject: [PATCH] #963 Fixes for the PGSQL, MYSQL and SQLITE extended libraries --- .../StatementBuilderTest.cs | 16 ---------------- .../StatementBuilders/MySqlStatementBuilder.cs | 16 ---------------- .../StatementBuilderTest.cs | 16 ---------------- .../MySqlConnectorStatementBuilder.cs | 16 ---------------- .../StatementBuilderTest.cs | 16 ---------------- .../PostgreSqlStatementBuilder.cs | 16 ---------------- .../StatementBuilderTest.cs | 16 ---------------- .../StatementBuilders/SqLiteStatementBuilder.cs | 16 ---------------- .../StatementBuilderTest.cs | 16 ---------------- .../StatementBuilders/SqLiteStatementBuilder.cs | 16 ---------------- 10 files changed, 160 deletions(-) diff --git a/RepoDb.MySql/RepoDb.MySql.UnitTests/StatementBuilderTest.cs b/RepoDb.MySql/RepoDb.MySql.UnitTests/StatementBuilderTest.cs index 11c356ab9..0e987754d 100644 --- a/RepoDb.MySql/RepoDb.MySql.UnitTests/StatementBuilderTest.cs +++ b/RepoDb.MySql/RepoDb.MySql.UnitTests/StatementBuilderTest.cs @@ -960,22 +960,6 @@ public void TestMySqlStatementBuilderCreateQueryOrderByFieldsMultiDirection() Assert.AreEqual(expected, query); } - [TestMethod, ExpectedException(typeof(MissingFieldsException))] - public void ThrowExceptionOnMySqlStatementBuilderCreateQueryIfOrderFieldsAreNotPresentAtTheFields() - { - // Setup - var builder = StatementBuilderMapper.Get(); - - // Act - builder.CreateQuery(new QueryBuilder(), - "Table", - Field.From("Id", "Name", "Address"), - null, - OrderField.Parse(new { Id = Order.Descending, SSN = Order.Ascending }), - null, - null); - } - [TestMethod, ExpectedException(typeof(NotSupportedException))] public void ThrowExceptionOnMySqlStatementBuilderCreateQueryIfThereAreHints() { diff --git a/RepoDb.MySql/RepoDb.MySql/StatementBuilders/MySqlStatementBuilder.cs b/RepoDb.MySql/RepoDb.MySql/StatementBuilders/MySqlStatementBuilder.cs index 011bf80f2..11c4b99d9 100644 --- a/RepoDb.MySql/RepoDb.MySql/StatementBuilders/MySqlStatementBuilder.cs +++ b/RepoDb.MySql/RepoDb.MySql/StatementBuilders/MySqlStatementBuilder.cs @@ -641,22 +641,6 @@ public override string CreateQuery(QueryBuilder queryBuilder, throw new NullReferenceException($"The list of queryable fields must not be null for '{tableName}'."); } - // Validate the ordering - if (orderBy != null) - { - // Check if the order fields are present in the given fields - var unmatchesOrderFields = orderBy.Where(orderField => - fields.FirstOrDefault(f => - string.Equals(orderField.Name, f.Name, StringComparison.OrdinalIgnoreCase)) == null); - - // Throw an error we found any unmatches - if (unmatchesOrderFields.Any() == true) - { - throw new MissingFieldsException($"The order fields '{unmatchesOrderFields.Select(field => field.Name).Join(", ")}' are not " + - $"present at the given fields '{fields.Select(field => field.Name).Join(", ")}'."); - } - } - // Initialize the builder var builder = queryBuilder ?? new QueryBuilder(); diff --git a/RepoDb.MySqlConnector/RepoDb.MySqlConnector.UnitTests/StatementBuilderTest.cs b/RepoDb.MySqlConnector/RepoDb.MySqlConnector.UnitTests/StatementBuilderTest.cs index a65cb704e..0c20e556e 100644 --- a/RepoDb.MySqlConnector/RepoDb.MySqlConnector.UnitTests/StatementBuilderTest.cs +++ b/RepoDb.MySqlConnector/RepoDb.MySqlConnector.UnitTests/StatementBuilderTest.cs @@ -960,22 +960,6 @@ public void TestMySqlStatementBuilderCreateQueryOrderByFieldsMultiDirection() Assert.AreEqual(expected, query); } - [TestMethod, ExpectedException(typeof(MissingFieldsException))] - public void ThrowExceptionOnMySqlStatementBuilderCreateQueryIfOrderFieldsAreNotPresentAtTheFields() - { - // Setup - var builder = StatementBuilderMapper.Get(); - - // Act - builder.CreateQuery(new QueryBuilder(), - "Table", - Field.From("Id", "Name", "Address"), - null, - OrderField.Parse(new { Id = Order.Descending, SSN = Order.Ascending }), - null, - null); - } - [TestMethod, ExpectedException(typeof(NotSupportedException))] public void ThrowExceptionOnMySqlStatementBuilderCreateQueryIfThereAreHints() { diff --git a/RepoDb.MySqlConnector/RepoDb.MySqlConnector/StatementBuilders/MySqlConnectorStatementBuilder.cs b/RepoDb.MySqlConnector/RepoDb.MySqlConnector/StatementBuilders/MySqlConnectorStatementBuilder.cs index a57b153e0..833428ca7 100644 --- a/RepoDb.MySqlConnector/RepoDb.MySqlConnector/StatementBuilders/MySqlConnectorStatementBuilder.cs +++ b/RepoDb.MySqlConnector/RepoDb.MySqlConnector/StatementBuilders/MySqlConnectorStatementBuilder.cs @@ -641,22 +641,6 @@ public override string CreateQuery(QueryBuilder queryBuilder, throw new NullReferenceException($"The list of queryable fields must not be null for '{tableName}'."); } - // Validate the ordering - if (orderBy != null) - { - // Check if the order fields are present in the given fields - var unmatchesOrderFields = orderBy.Where(orderField => - fields.FirstOrDefault(f => - string.Equals(orderField.Name, f.Name, StringComparison.OrdinalIgnoreCase)) == null); - - // Throw an error we found any unmatches - if (unmatchesOrderFields.Any() == true) - { - throw new MissingFieldsException($"The order fields '{unmatchesOrderFields.Select(field => field.Name).Join(", ")}' are not " + - $"present at the given fields '{fields.Select(field => field.Name).Join(", ")}'."); - } - } - // Initialize the builder var builder = queryBuilder ?? new QueryBuilder(); diff --git a/RepoDb.PostgreSql/RepoDb.PostgreSql.UnitTests/StatementBuilderTest.cs b/RepoDb.PostgreSql/RepoDb.PostgreSql.UnitTests/StatementBuilderTest.cs index 78e9342f2..e950be71f 100644 --- a/RepoDb.PostgreSql/RepoDb.PostgreSql.UnitTests/StatementBuilderTest.cs +++ b/RepoDb.PostgreSql/RepoDb.PostgreSql.UnitTests/StatementBuilderTest.cs @@ -961,22 +961,6 @@ public void TestPostgreSqlStatementBuilderCreateQueryOrderByFieldsMultiDirection Assert.AreEqual(expected, query); } - [TestMethod, ExpectedException(typeof(MissingFieldsException))] - public void ThrowExceptionOnPostgreSqlStatementBuilderCreateQueryIfOrderFieldsAreNotPresentAtTheFields() - { - // Setup - var builder = StatementBuilderMapper.Get(); - - // Act - builder.CreateQuery(new QueryBuilder(), - "Table", - Field.From("Id", "Name", "Address"), - null, - OrderField.Parse(new { Id = Order.Descending, SSN = Order.Ascending }), - null, - null); - } - [TestMethod, ExpectedException(typeof(NotSupportedException))] public void ThrowExceptionOnPostgreSqlStatementBuilderCreateQueryIfThereAreHints() { diff --git a/RepoDb.PostgreSql/RepoDb.PostgreSql/StatementBuilders/PostgreSqlStatementBuilder.cs b/RepoDb.PostgreSql/RepoDb.PostgreSql/StatementBuilders/PostgreSqlStatementBuilder.cs index 70f8d1973..4b4aac3a9 100644 --- a/RepoDb.PostgreSql/RepoDb.PostgreSql/StatementBuilders/PostgreSqlStatementBuilder.cs +++ b/RepoDb.PostgreSql/RepoDb.PostgreSql/StatementBuilders/PostgreSqlStatementBuilder.cs @@ -582,22 +582,6 @@ public override string CreateQuery(QueryBuilder queryBuilder, throw new NullReferenceException($"The list of queryable fields must not be null for '{tableName}'."); } - // Validate the ordering - if (orderBy != null) - { - // Check if the order fields are present in the given fields - var unmatchesOrderFields = orderBy.Where(orderField => - fields.FirstOrDefault(f => - string.Equals(orderField.Name, f.Name, StringComparison.OrdinalIgnoreCase)) == null); - - // Throw an error we found any unmatches - if (unmatchesOrderFields.Any() == true) - { - throw new MissingFieldsException($"The order fields '{unmatchesOrderFields.Select(field => field.Name).Join(", ")}' are not " + - $"present at the given fields '{fields.Select(field => field.Name).Join(", ")}'."); - } - } - // Initialize the builder var builder = queryBuilder ?? new QueryBuilder(); diff --git a/RepoDb.SQLite.System/RepoDb.SQLite.System.UnitTests/StatementBuilderTest.cs b/RepoDb.SQLite.System/RepoDb.SQLite.System.UnitTests/StatementBuilderTest.cs index 20ad22a9c..30fb39b6b 100644 --- a/RepoDb.SQLite.System/RepoDb.SQLite.System.UnitTests/StatementBuilderTest.cs +++ b/RepoDb.SQLite.System/RepoDb.SQLite.System.UnitTests/StatementBuilderTest.cs @@ -731,22 +731,6 @@ public void TestSdsSqLiteStatementBuilderCreateQueryOrderByFieldsMultiDirection( Assert.AreEqual(expected, query); } - [TestMethod, ExpectedException(typeof(MissingFieldsException))] - public void ThrowExceptionOnSqLiteStatementBuilderCreateQueryIfOrderFieldsAreNotPresentAtTheFields() - { - // Setup - var builder = StatementBuilderMapper.Get(); - - // Act - builder.CreateQuery(new QueryBuilder(), - "Table", - Field.From("Id", "Name", "Address"), - null, - OrderField.Parse(new { Id = Order.Descending, SSN = Order.Ascending }), - null, - null); - } - [TestMethod, ExpectedException(typeof(NotSupportedException))] public void ThrowExceptionOnSqLiteStatementBuilderCreateQueryIfThereAreHints() { diff --git a/RepoDb.SQLite.System/RepoDb.SQLite.System/StatementBuilders/SqLiteStatementBuilder.cs b/RepoDb.SQLite.System/RepoDb.SQLite.System/StatementBuilders/SqLiteStatementBuilder.cs index 169823142..76d1e8fa4 100644 --- a/RepoDb.SQLite.System/RepoDb.SQLite.System/StatementBuilders/SqLiteStatementBuilder.cs +++ b/RepoDb.SQLite.System/RepoDb.SQLite.System/StatementBuilders/SqLiteStatementBuilder.cs @@ -540,22 +540,6 @@ public override string CreateQuery(QueryBuilder queryBuilder, throw new NullReferenceException($"The list of queryable fields must not be null for '{tableName}'."); } - // Validate the ordering - if (orderBy != null) - { - // Check if the order fields are present in the given fields - var unmatchesOrderFields = orderBy.Where(orderField => - fields.FirstOrDefault(f => - string.Equals(orderField.Name, f.Name, StringComparison.OrdinalIgnoreCase)) == null); - - // Throw an error we found any unmatches - if (unmatchesOrderFields.Any() == true) - { - throw new MissingFieldsException($"The order fields '{unmatchesOrderFields.Select(field => field.Name).Join(", ")}' are not " + - $"present at the given fields '{fields.Select(field => field.Name).Join(", ")}'."); - } - } - // Initialize the builder var builder = queryBuilder ?? new QueryBuilder(); diff --git a/RepoDb.Sqlite.Microsoft/RepoDb.Sqlite.Microsoft.UnitTests/StatementBuilderTest.cs b/RepoDb.Sqlite.Microsoft/RepoDb.Sqlite.Microsoft.UnitTests/StatementBuilderTest.cs index f2c42db5f..721033df2 100644 --- a/RepoDb.Sqlite.Microsoft/RepoDb.Sqlite.Microsoft.UnitTests/StatementBuilderTest.cs +++ b/RepoDb.Sqlite.Microsoft/RepoDb.Sqlite.Microsoft.UnitTests/StatementBuilderTest.cs @@ -731,22 +731,6 @@ public void TestMdsSqLiteStatementBuilderCreateQueryOrderByFieldsMultiDirection( Assert.AreEqual(expected, query); } - [TestMethod, ExpectedException(typeof(MissingFieldsException))] - public void ThrowExceptionOnMdsSqLiteStatementBuilderCreateQueryIfOrderFieldsAreNotPresentAtTheFields() - { - // Setup - var builder = StatementBuilderMapper.Get(); - - // Act - builder.CreateQuery(new QueryBuilder(), - "Table", - Field.From("Id", "Name", "Address"), - null, - OrderField.Parse(new { Id = Order.Descending, SSN = Order.Ascending }), - null, - null); - } - [TestMethod, ExpectedException(typeof(NotSupportedException))] public void ThrowExceptionOnMdsSqLiteStatementBuilderCreateQueryIfThereAreHints() { diff --git a/RepoDb.Sqlite.Microsoft/RepoDb.Sqlite.Microsoft/StatementBuilders/SqLiteStatementBuilder.cs b/RepoDb.Sqlite.Microsoft/RepoDb.Sqlite.Microsoft/StatementBuilders/SqLiteStatementBuilder.cs index 169823142..76d1e8fa4 100644 --- a/RepoDb.Sqlite.Microsoft/RepoDb.Sqlite.Microsoft/StatementBuilders/SqLiteStatementBuilder.cs +++ b/RepoDb.Sqlite.Microsoft/RepoDb.Sqlite.Microsoft/StatementBuilders/SqLiteStatementBuilder.cs @@ -540,22 +540,6 @@ public override string CreateQuery(QueryBuilder queryBuilder, throw new NullReferenceException($"The list of queryable fields must not be null for '{tableName}'."); } - // Validate the ordering - if (orderBy != null) - { - // Check if the order fields are present in the given fields - var unmatchesOrderFields = orderBy.Where(orderField => - fields.FirstOrDefault(f => - string.Equals(orderField.Name, f.Name, StringComparison.OrdinalIgnoreCase)) == null); - - // Throw an error we found any unmatches - if (unmatchesOrderFields.Any() == true) - { - throw new MissingFieldsException($"The order fields '{unmatchesOrderFields.Select(field => field.Name).Join(", ")}' are not " + - $"present at the given fields '{fields.Select(field => field.Name).Join(", ")}'."); - } - } - // Initialize the builder var builder = queryBuilder ?? new QueryBuilder();