Skip to content

feat: [#358] Implement ToSql, ToRawSql methods#934

Merged
hwbrzzl merged 3 commits intomasterfrom
bowen/#358-13
Mar 4, 2025
Merged

feat: [#358] Implement ToSql, ToRawSql methods#934
hwbrzzl merged 3 commits intomasterfrom
bowen/#358-13

Conversation

@hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Mar 4, 2025

📑 Description

goravel/goravel#358

@coderabbitai summary

✅ Checks

  • Added test cases for my code

Copilot AI review requested due to automatic review settings March 4, 2025 03:28
@hwbrzzl hwbrzzl requested a review from a team as a code owner March 4, 2025 03:28
@codecov
Copy link

codecov bot commented Mar 4, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.16%. Comparing base (da297ba) to head (42e77c3).
Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #934   +/-   ##
=======================================
  Coverage   69.16%   69.16%           
=======================================
  Files         157      157           
  Lines       10519    10519           
=======================================
  Hits         7275     7275           
  Misses       2911     2911           
  Partials      333      333           

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

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 the ToSql and ToRawSql methods for database query generation and updates various mock, query, logger, and DB functionalities to support the new SQL generation interfaces.

  • Added ToSql/ToRawSql methods to the Query and ToSql types.
  • Updated the mocks (e.g. ToSql, Query, Driver) and error messages for consistency.
  • Refactored logger and DB provider methods to use the updated logger interface (Infof, Warningf, Errorf, Panicf).

Reviewed Changes

File Description
mocks/database/db/ToSql.go New autogenerated mock methods for ToSql and related signatures.
database/db/to_sql.go Implementation of ToSql methods and adjusted error handling.
database/db/query.go Introduced ToSql and ToRawSql methods and modified Insert behavior.
database/logger/logger.go Renamed logging methods to Infof/Warningf/Errorf/Panicf and added WithContext usage.
contracts/database/db/db.go Updated the Query interface documentation for ToSql/ToRawSql.
errors/list.go Added new error messages for SQL generation failures and empty data.
mocks/database/driver/Driver.go Renamed parameters in Explain methods for consistency.
database/db/db.go Updated DB construction to use the new logger interface.
contracts/database/driver/driver.go Updated the Explain method signature to reflect renamed parameters.
tests/query.go Updated test dependencies to use the new logger implementation.
database/service_provider.go Adjusted DB build process to use the new logger.

Copilot reviewed 17 out of 17 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (3)

mocks/database/driver/Driver.go:192

  • The parameter name 'vars' has been updated to 'args' to match the driver interface; please verify that all related mock methods consistently use 'args' in both definition and invocation.
r0 = rf(_a0, vars...)

database/db/query.go:271

  • This change alters the behavior of Insert by returning an error (DatabaseDataIsEmpty) instead of a Result with zero rows; please confirm that downstream code correctly handles a nil result when data is empty.
if len(mapData) == 0 { return nil, errors.DatabaseDataIsEmpty }

database/logger/logger.go:52

  • The logger methods have been refactored to use WithContext(ctx) prior to logging; please ensure that all underlying logger implementations support this context propagation without affecting log formatting.
r.log.WithContext(ctx).Infof(msg, data...)

@hwbrzzl hwbrzzl merged commit 3528add into master Mar 4, 2025
14 checks passed
@hwbrzzl hwbrzzl deleted the bowen/#358-13 branch March 4, 2025 03:53
almas-x pushed a commit that referenced this pull request Mar 12, 2025
* feat: [#358] Implement ToSql, ToRawSql methods

* fix tests

* fix tests
almas-x pushed a commit that referenced this pull request Mar 18, 2025
* feat: [#358] Implement ToSql, ToRawSql methods

* fix tests

* fix tests
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