Skip to content

feat: [#358] Implement Sqlite Mysql drivers#950

Merged
hwbrzzl merged 2 commits intomasterfrom
bowen/#358-20
Mar 9, 2025
Merged

feat: [#358] Implement Sqlite Mysql drivers#950
hwbrzzl merged 2 commits intomasterfrom
bowen/#358-20

Conversation

@hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Mar 9, 2025

📑 Description

goravel/goravel#358

This pull request includes several changes to the database driver and tests. The most important changes include adding new methods to the Schema and Blueprint interfaces, updating dependencies, and modifying test cases to ensure proper functionality and cleanup.

Interface Enhancements:

  • Added GetColumns, GetIndexes, and Orm methods to the Schema interface in contracts/database/driver/grammar.go.
  • Added GetCommands method to the Blueprint interface in contracts/database/driver/grammar.go.

Dependency Updates:

  • Updated mapstructure import in database/db/row.go to use github.com/go-viper/mapstructure/v2.
  • Added new dependencies in tests/go.mod such as github.com/goravel/mysql, github.com/goravel/sqlite, and others. [1] [2] [3] [4]

Test Modifications:

  • Enabled previously commented-out test cases and added new ones in tests/db_test.go to ensure proper functionality of database operations. [1] [2] [3]
  • Updated SetupTest and TearDownSuite methods in tests/db_test.go and tests/migrator_test.go to handle Docker shutdown for SQLite. [1] [2]

Code Simplification:

  • Simplified the Chunk method in database/db/query.go by directly appending rows to the destination slice.

Mock Enhancements:

  • Added mock functions for GetColumns, GetIndexes, and Orm methods in mocks/database/driver/Schema.go.

These changes collectively improve the functionality, maintainability, and test coverage of the database driver and related components.

✅ Checks

  • Added test cases for my code

@codecov
Copy link

codecov bot commented Mar 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.15%. Comparing base (52dee9c) to head (3f81b10).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #950   +/-   ##
=======================================
  Coverage   69.15%   69.15%           
=======================================
  Files         157      157           
  Lines       10526    10526           
=======================================
  Hits         7279     7279           
  Misses       2913     2913           
  Partials      334      334           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hwbrzzl hwbrzzl marked this pull request as ready for review March 9, 2025 06:44
Copilot AI review requested due to automatic review settings March 9, 2025 06:44
@hwbrzzl hwbrzzl requested a review from a team as a code owner March 9, 2025 06:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Overview

This PR implements new SQLite/MySQL driver methods and updates the test suite to ensure proper functionality and cleanup. Key changes include:

  • Adding new methods to the Schema and Blueprint interfaces and their corresponding mocks.
  • Updating dependency imports and adding a new decode hook (ToStringHookFunc) for proper MySQL string conversion.
  • Enabling and refactoring several test cases (e.g. InsertGetId, LockForUpdate, DB connection tests) for improved coverage and reliability.

Reviewed Changes

File Description
mocks/database/driver/Schema.go Added GetColumns/GetIndexes/Orm methods and associated mock helpers.
mocks/database/driver/Blueprint.go Added GetCommands method for Blueprint mocks.
tests/db_test.go Updated test cases and Docker shutdown handling for SQLite.
database/db/row.go Updated dependency import and added ToStringHookFunc for MySQL support.
tests/query_test.go Enabled previously commented-out tests and refined test logic.
contracts/database/driver/grammar.go Enhanced Schema and Blueprint interfaces with new methods.
database/db/query.go Simplified the Chunk method by appending rows directly.
tests/migrator_test.go Un-commented and updated SQLServer migration tests.
tests/orm_test.go Updated tear down logic for SQLite Docker shutdown.
tests/query.go Un-commented MySQL/SQLite related code in TestQueryBuilder and mix functions.
tests/repository_test.go Updated Docker shutdown handling in repository tests.
tests/mock_config.go Updated mock configuration expectations for database connections.

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

@hwbrzzl hwbrzzl merged commit 9a7bcbe into master Mar 9, 2025
11 of 13 checks passed
@hwbrzzl hwbrzzl deleted the bowen/#358-20 branch March 9, 2025 08:25
almas-x pushed a commit that referenced this pull request Mar 12, 2025
* feat: Implement Sqlite Mysql drivers

* fix test
almas-x pushed a commit that referenced this pull request Mar 18, 2025
* feat: Implement Sqlite Mysql drivers

* fix test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants