Open malikrafsan opened 4 months ago
From what I understand, .NET provides the interface and abstract class for the database connector as well -> IDbDataAdapter, IDbConnection, IDbCommand, IDbDataParameter, IDbTransaction
I think there are 3 possible approaches that we can take
We discussed this and decided to pick the first and second options
Previously I used release results. However, this is incompatible with the current code. The solution is that we need to build the Polypheny server locally. I build it using Polypheny Control
The PR: https://github.com/polypheny/Polypheny-DotNet-Driver/pull/3
After learning directly from MySQL Connector codes, it would be better to change the function to be a wrapper of the async function. For example, in the Open method, we implement it by calling the OpenAsync method and await the result then return it. Here I try to do it by using the async variants of Read and Write methods from TCP NetworkStream. The implication is that Send and Receive methods using protobuf are async methods as well. By this approach, we convert these methods into wrappers of async methods:
Class DbCommand from .NET which we inherit, uses two interfaces to send SQL commands to the database, which are ExecuteNonQuery
and ExecuteDbDataReader
. ExecuteNonQuery
is used for data manipulation and schema definition, whereas ExecuteDbDataReader
is used for query.
In this progress, we have implemented the ExecuteNonQuery
method successfully with its test as well.
In this progress, we also have implemented the prepared functionality to include parameters in the SQL command.
Here is the screenshot of the test. In the test, we insert a row by passing parameterized values using ?
mark
In this progress, we also migrate from importing Prism Protobuf manually to importing from Nuget Package. By this approach, we centralized the management of the Prism Protobuf to the Nuget package and do not manage it directly in the driver code
As mentioned previously, Class DbCommand from .NET which we inherit, uses two interfaces to send SQL commands to the database, which are ExecuteNonQuery and ExecuteDbDataReader. ExecuteNonQuery is used for data manipulation and schema definition, whereas ExecuteDbDataReader is used for query.
In this progress, we have implemented the ExecuteDbDataReader
and its related methods. Those methods will return PolyphenyDataReader
which inherits from DbDataReader
. This class allows the user to read the query result from the database
In this progress, we also add the test case for the Execute Query Functionality. The test case will test whether the driver is able to query the database. We add two test cases.
The left image shows the first case whereas the middle image shows the second case. The test result is shown in the right image
Polypheny also supports document-based databases. In this implementation, we add an interface for executing Mongo-like queries for document-based databases. This interface will return an array of dictionaries, representing document data
In this progress, we also add the test case for the Execute Query Mongo. The test case will test whether the driver is able to query the document-based database. We add two test cases.
In this progress, we also change and implement minor additions, such as
As Polypheny supports SQL databases, one of the main features of SQL databases is ACID properties. To ensure ACID properties, a transaction feature is needed to be implemented. This week, we implemented PolyphenyTransaction. PolyphenyTransaction is a class for managing transaction features. We also made adjustments needed for this feature to the other classes as well. By implementing this feature, we can have multiple queries that work as one unit (one transaction).
This class has two methods, which are Commit and Rollback. Commit is used to make the changes in that transaction permanent. Whereas Rollback is used to cancel all of the changes in that transaction.
In this week, we also add test cases for the transaction feature. These test cases are used to test the Commit and Rollback interfaces. Commit is tested with a scenario in which we select a table that is inserted and committed in a transaction. Rollback is tested with a scenario in which we select a table that is inserted and rollbacked.
To increase the reliability of the driver, we need to add more tests to ensure that the code works properly and can be maintained easily. To quantify the testing, we can add code coverage to the driver. We need to visualize the code coverage properly to better view the code coverage result. We use the NUnit package to calculate the code coverage and output the report in cobertura format. We visualize the report by using reportgenerator
library, which outputs HTML and related files. Here is the visualization of the current report
We also add the test cases for the PolyphenyDataReader and ProtoHelper classes. This is still ongoing progress as there are still a lot of classes and methods that need to be tested
In order to increase the reliability of the driver, we need to increase the test for the driver. One metric that is useful for this case is code coverage. Previously, we have set up the mechanism to calculate and visualize the code coverage. However, some codes are still low in code coverage because it is harder to test.
In order to make it easier to test and in turn increase the code coverage, we refactor the code using interface pattern and dependency injection pattern. With this pattern, we can easily make unit tests using mock interfaces that work as intended without being dependent on other parts of the code. Here is an example
As previously mentioned, we intend to increase the code coverage. After doing the refactor, it is much easier to add new unit tests to cover other parts of the code that are harder to test using end-to-end testing. We have successfully increase the code coverage to be 90% for line coverage and 78% for branch coverage
To make it easier for the developers to use this driver, we added a demo project that contains a lot of code examples to use this driver. By doing this, the developers who want to use this driver can take a look at the code examples and customize them by their needs. The demo project can be access at here
In addition to the demo project, we also added more explanation in the README file of the project. This README file also can make it easier for the developers who want to use this driver. The README file covers several stuff for the project, ranging from how to setup, how to use, code examples, and how to test the driver.
Description
This issue will contain and track about the progress of this project (Polypheny .NET Driver)