Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced greenDAO with androidx.room #506

Draft
wants to merge 101 commits into
base: develop
Choose a base branch
from
Draft

Conversation

JaniruTEC
Copy link
Contributor

@JaniruTEC JaniruTEC commented Oct 18, 2023

Summary by CodeRabbit

  • New Features

    • Introduced Room library for enhanced database management.
    • Added new tests for database creation, access, and migrations.
    • Implemented automatic and manual database migrations for improved data integrity.
    • Added new data access objects (DAOs) for Cloud, Update Check, and Vault entities.
  • Enhancements

    • Improved database operation efficiency by utilizing Kotlin's type alias and constructor-based entity creation.
    • Enhanced database schema with the addition of entities for Cloud, Update Check, and Vault.
    • Streamlined database access in repository implementations with dependency injection.
  • Bug Fixes

    • Fixed issues related to database migrations and entity mapping for a more stable user experience.
  • Refactor

    • Transitioned from GreenDao to Room for database operations, resulting in cleaner and more maintainable code.
    • Refined database migration logic to use Room's built-in migration features.
  • Documentation

    • Updated internal comments to reflect changes in database handling and migration processes.
  • Chores

    • Updated build configurations to include necessary Room library dependencies.

Replaced greenDAO dependency with androidx.room
Introduced database version 13
Introduced database version 14
@JaniruTEC JaniruTEC marked this pull request as draft October 18, 2023 13:52
@CLAassistant

This comment was marked as resolved.

*This commit is related to issue #529 [1]*

[1] #529
This also makes the class compatible with "MappingSupportSQLiteDatabase"

*This commit is related to issue #529 [1]*

[1] #529
This also makes the test method compatible with "MappingSupportSQLiteDatabase"
Also added "assertIsUUID"

*This commit is related to issue #529 [1]*

[1] #529
See: b3449f0
Also See: c13b12f

*This commit is related to issue #529 [1]*

[1] #529
Added "ValueExtractor<T>" as type alias for "(T) -> Any?"
Changed argument declarations of "pseudo equality" methods and underlying implementations
Added "ValueExtractor<T>" as type declaration for existing value extractor sets

*This commit is related to issue #529 [1]*

[1] #529
Also added workaround for tests

*This commit is related to issue #529 [1]*

[1] #529
Changed "insert" to directly compile the mapped sql instead of creating a "MappingSupportSQLiteStatement"
Added check if the database is open to "compileStatement"

*This commit is related to issue #529 [1]*

[1] #529
*This commit is related to issue #529 [1]*

[1] #529
Also added missing "@VisibleForTesting" annotation to "MappingSupportSQLiteDatabase"

*This commit is related to issue #529 [1]*

[1] #529
Added additional validation
Moved database operations to "use" blocks
If database corruption is detected the database is deleted and then recreated. Properly recreating and opening the new database involves invalidating any references to the old database and then running any initialization logic.

Added "Invalidatable" as wrapper for database references
Added "DatabaseOpenHelperFactory" to the dagger graph and added invalidation logic to "PatchedCallback"
Added dynamically delegating implementations for all entities to allow seamless swapping of underlying database instances
Configured Room to initialize based on the database template if a database with version 0 is encountered
Also added "databaseName" to parameter list of "provideInternalCryptomatorDatabase" to allow different names for test databases
Added missing message in "CryptomatorAssert"
Fixed imports and codestyle
Added missing call to "disableWriteAheadLogging"
Made instance of "AOP_SQLiteDatabase" in "MappingSupportSQLiteDatabase" static
This creates a single source of truth for configuring the main database and any tests.
"PatchedCallback" and "DatabaseOpenHelperFactoryKt.patchConfiguration" interact with the inner classes of "SupportSQLiteOpenHelper" in a way that is prone to introducing bugs due to unnoticed changes to those classes.
The tests introduced by this commit ensure that changes to the bills of materials for those classes are noticed and handled in the future.
…iteDatabase"

*This commit is related to issue #529 [1]*

[1] #529
Moved tests from android tests to unit tests
Renamed containing class from "DatabaseOpenHelperFactoryTest" to "BomVerificationTest"
Fixed failing tests due to differences in JDK distros

*This commit is related to issue #529 [1]*

[1] #529
Added sorting of BOMs to ease debugging
Added check for classes that can't be verified by a unit test

*This commit is related to issue #529 [1]*

[1] #529
Added inner class "MappingSupportSQLiteStatementTest" to "MappingSupportSQLiteDatabaseTest" and included an additional counter-based mapping
Added test "testNewBoundStatementSingle": Run "newBoundStatement" three times on the same "MappingSupportSQLiteStatement" (with the same unmapped sql strings and the same backing mapping)
Added test "testNewBoundStatementMultiple": Run "newBoundStatement" on three different instances of "MappingSupportSQLiteStatement" (with the same/different unmapped sql strings and per-statement backing mappings)
Added matching data sets for tests
Added a number of utility methods
Refactored "cartesianProduct" methods
Refactored extension methods for "ContentValues" defined in "MappingSupportSQLiteDatabaseTest.kt" and mirrored them for "Iterable<Any?>?"
Changed visibility of "MappingSupportSQLiteStatement.newBoundStatement" to "internal" and annotated it with "@VisibleForTesting"

*This commit is related to issue #529 [1]*

[1] #529
Also added matching data sets
Added method "cartesianProductFour"

*This commit is related to issue #529 [1]*

[1] #529
Unified the implementation of "testInsert" with the implemention of all tests contained in "MappingSupportSQLiteStatementTest" by first augmenting and moving the implementation of "testSingleNewBoundStatement" to a new method "testSingleCompiledStatement" and then using that method in "testInsert":
> Previous control flows:
>> "testNewBoundStatementX" -> ("testConsecutiveNewBoundStatements" ->) "testConsecutiveNewBoundStatements" -> "testSingleNewBoundStatement" -> *Verifications*
>> "testInsert" -> *Verifications*
> New control flows:
>> "testNewBoundStatementX" -> ("testConsecutiveNewBoundStatements" ->) "testConsecutiveNewBoundStatements" -> "testSingleNewBoundStatement" -> "testSingleCompiledStatement" -> *Verifications*
>> "testInsert" -> "testSingleInsert" -> "testSingleCompiledStatement" -> *Verifications*

Removed extensions methods for "ContentValues" defined in "MappingSupportSQLiteDatabaseTest.kt" and replaced usages with calls to corresponding extension methods for "Iterable<Any?>?" defined in "MappingSupportSQLiteDatabaseTest.kt"

*This commit is related to issue #529 [1]*

[1] #529
*This commit is related to issue #529 [1]*

[1] #529
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants