Skip to content
Merged
2 changes: 1 addition & 1 deletion .github/workflows/publish-nuget-Package.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Publish Nuget Package

env:
NUGET_PACKAGE_NAME_VERSION: "QueryDB.1.2.0.nupkg"
NUGET_PACKAGE_NAME_VERSION: "QueryDB.1.3.0.nupkg"

on:
workflow_dispatch:
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ All notable changes to this project documented here.

## [Released]

## [1.3.0](https://www.nuget.org/packages/QueryDB/1.3.0) - 2025-07-27
### Changed
- Seal adapter classes for better encapsulation.
- Restrict fetch data to SELECT commands.
- Refactoring DBContext to use switch statement for improved clarity and structure.

## [1.2.0](https://www.nuget.org/packages/QueryDB/1.2.0) - 2025-03-04
### Added
- Asynchronous operations
Expand All @@ -11,7 +17,7 @@ All notable changes to this project documented here.
- `ExecuteCommandAsync()`
- `ExecuteTransactionAsync()`
### Changed
- Execute transaction to return transaction outcome and exception details in case of failure instead of logging into console.
- Execute transaction to return transaction outcome and exception details in case of failure instead of logging into console.

## [1.1.0](https://www.nuget.org/packages/QueryDB/1.1.0) - 2025-02-20
### Added
Expand Down
2 changes: 1 addition & 1 deletion QueryDB.Core.Tests/Docker/docker-compose-oracle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ services:
image: container-registry.oracle.com/database/express:21.3.0-xe
container_name: oracle-db
environment:
ORACLE_PWD: "Secret123456"
ORACLE_PWD: ""
ports:
- "1521:1521"
volumes:
Expand Down
148 changes: 148 additions & 0 deletions QueryDB.Core.Tests/MSSQLTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,43 @@ public void Test_MSSQL_FetchData_Dictionary_DataTypes_Check()
Assert.AreEqual("<root><element>XmlData</element></root>", dataType.ReferenceData["Xml_Column"]);
}

[TestMethod]
[TestCategory(DB_TESTS), TestCategory(MSSQL_TESTS)]
public void Test_MSSQL_FetchData_Dictionary_UnsupportedCommands()
{
var sqlStatements = new List<string>
{
Queries.MSSQLQueries.TestDB.DDL.Create_Table,
Queries.MSSQLQueries.TestDB.DDL.Alter_Table,
Queries.MSSQLQueries.TestDB.DDL.Comment_Table,
Queries.MSSQLQueries.TestDB.DDL.Truncate_Table,
Queries.MSSQLQueries.TestDB.DDL.Drop_Table,

Queries.MSSQLQueries.TestDB.DML.InsertSql,
Queries.MSSQLQueries.TestDB.DML.UpdateSql,
Queries.MSSQLQueries.TestDB.DML.DeleteSql,

Queries.MSSQLQueries.TestDB.DCL.GrantSql_Command_Table_User,
Queries.MSSQLQueries.TestDB.DCL.RevokeSql_Command_Table_User
};

foreach (var sqlStatement in sqlStatements)
{
try
{
var dbContext = new DBContext(DB.MSSQL, MSSQLConnectionString);
dbContext.FetchData(sqlStatement);
Assert.Fail("No Exception");
}
catch (QueryDBException ex)
{
Assert.AreEqual("Only SELECT queries are supported here.", ex.Message);
Assert.AreEqual("UnsupportedCommand", ex.ErrorType);
Assert.AreEqual("'FetchData' only supports SELECT queries that return result set.", ex.AdditionalInfo);
}
}
}

#endregion

#region Fetch Data Async Tests - << Task<List<DataDictionary>> FetchDataAsync(string selectSql, bool upperCaseKeys = false) >>
Expand Down Expand Up @@ -316,6 +353,43 @@ public async Task Test_MSSQL_FetchDataAsync_Dictionary_DataTypes_Check()
Assert.AreEqual("<root><element>XmlData</element></root>", dataType.ReferenceData["Xml_Column"]);
}

[TestMethod]
[TestCategory(DB_TESTS), TestCategory(MSSQL_TESTS)]
public async Task Test_MSSQL_FetchDataAsync_Dictionary_UnsupportedCommands()
{
var sqlStatements = new List<string>
{
Queries.MSSQLQueries.TestDB.DDL.Create_Table,
Queries.MSSQLQueries.TestDB.DDL.Alter_Table,
Queries.MSSQLQueries.TestDB.DDL.Comment_Table,
Queries.MSSQLQueries.TestDB.DDL.Truncate_Table,
Queries.MSSQLQueries.TestDB.DDL.Drop_Table,

Queries.MSSQLQueries.TestDB.DML.InsertSql,
Queries.MSSQLQueries.TestDB.DML.UpdateSql,
Queries.MSSQLQueries.TestDB.DML.DeleteSql,

Queries.MSSQLQueries.TestDB.DCL.GrantSql_Command_Table_User,
Queries.MSSQLQueries.TestDB.DCL.RevokeSql_Command_Table_User
};

foreach (var sqlStatement in sqlStatements)
{
try
{
var dbContext = new DBContext(DB.MSSQL, MSSQLConnectionString);
await dbContext.FetchDataAsync(sqlStatement);
Assert.Fail("No Exception");
}
catch (QueryDBException ex)
{
Assert.AreEqual("Only SELECT queries are supported here.", ex.Message);
Assert.AreEqual("UnsupportedCommand", ex.ErrorType);
Assert.AreEqual("'FetchData' only supports SELECT queries that return result set.", ex.AdditionalInfo);
}
}
}

#endregion

#region Fetch Data Tests - << List<T> FetchData<T>(string selectSql, bool strict = false) >>
Expand Down Expand Up @@ -453,6 +527,43 @@ public void Test_MSSQL_FetchData_Entity_Strict_Error_Check()
}
}

[TestMethod]
[TestCategory(DB_TESTS), TestCategory(MSSQL_TESTS)]
public void Test_MSSQL_FetchData_Entity_UnsupportedCommands()
{
var sqlStatements = new List<string>
{
Queries.MSSQLQueries.TestDB.DDL.Create_Table,
Queries.MSSQLQueries.TestDB.DDL.Alter_Table,
Queries.MSSQLQueries.TestDB.DDL.Comment_Table,
Queries.MSSQLQueries.TestDB.DDL.Truncate_Table,
Queries.MSSQLQueries.TestDB.DDL.Drop_Table,

Queries.MSSQLQueries.TestDB.DML.InsertSql,
Queries.MSSQLQueries.TestDB.DML.UpdateSql,
Queries.MSSQLQueries.TestDB.DML.DeleteSql,

Queries.MSSQLQueries.TestDB.DCL.GrantSql_Command_Table_User,
Queries.MSSQLQueries.TestDB.DCL.RevokeSql_Command_Table_User
};

foreach (var sqlStatement in sqlStatements)
{
try
{
var dbContext = new DBContext(DB.MSSQL, MSSQLConnectionString);
dbContext.FetchData<Entities.MSSQL.Orders>(sqlStatement);
Assert.Fail("No Exception");
}
catch (QueryDBException ex)
{
Assert.AreEqual("Only SELECT queries are supported here.", ex.Message);
Assert.AreEqual("UnsupportedCommand", ex.ErrorType);
Assert.AreEqual("'FetchData' only supports SELECT queries that return result set.", ex.AdditionalInfo);
}
}
}

#endregion

#region Fetch Data Async Tests - << Task<List<T>> FetchDataAsync<T>(string selectSql, bool strict = false) >>
Expand Down Expand Up @@ -590,6 +701,43 @@ public async Task Test_MSSQL_FetchDataAsync_Entity_Strict_Error_Check()
}
}

[TestMethod]
[TestCategory(DB_TESTS), TestCategory(MSSQL_TESTS)]
public async Task Test_MSSQL_FetchDataAsync_Entity_UnsupportedCommands()
{
var sqlStatements = new List<string>
{
Queries.MSSQLQueries.TestDB.DDL.Create_Table,
Queries.MSSQLQueries.TestDB.DDL.Alter_Table,
Queries.MSSQLQueries.TestDB.DDL.Comment_Table,
Queries.MSSQLQueries.TestDB.DDL.Truncate_Table,
Queries.MSSQLQueries.TestDB.DDL.Drop_Table,

Queries.MSSQLQueries.TestDB.DML.InsertSql,
Queries.MSSQLQueries.TestDB.DML.UpdateSql,
Queries.MSSQLQueries.TestDB.DML.DeleteSql,

Queries.MSSQLQueries.TestDB.DCL.GrantSql_Command_Table_User,
Queries.MSSQLQueries.TestDB.DCL.RevokeSql_Command_Table_User
};

foreach (var sqlStatement in sqlStatements)
{
try
{
var dbContext = new DBContext(DB.MSSQL, MSSQLConnectionString);
await dbContext.FetchDataAsync<Entities.MSSQL.Orders>(sqlStatement);
Assert.Fail("No Exception");
}
catch (QueryDBException ex)
{
Assert.AreEqual("Only SELECT queries are supported here.", ex.Message);
Assert.AreEqual("UnsupportedCommand", ex.ErrorType);
Assert.AreEqual("'FetchData' only supports SELECT queries that return result set.", ex.AdditionalInfo);
}
}
}

#endregion

#region Execute Scalar Tests - << string ExecuteScalar(string sqlStatement) >>
Expand Down
Loading