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

fix: Problem with submodels id string #903

Merged
merged 1 commit into from
Feb 21, 2025
Merged

fix: Problem with submodels id string #903

merged 1 commit into from
Feb 21, 2025

Conversation

hwbrzzl
Copy link
Contributor

@hwbrzzl hwbrzzl commented Feb 21, 2025

📑 Description

Summary by CodeRabbit

  • New Features

    • Enhanced database schema support with new boolean and custom column types.
    • Added an extra CLI configuration option for improved command behavior.
  • Refactor

    • Consolidated binding references and standardized naming across multiple services.
    • Unified timestamp management in tests to ensure consistency.
    • Revised logging outputs and messaging for clearer communication.
  • Tests

    • Expanded test coverage to validate new schema types and CLI changes.
  • Chores

    • Upgraded numerous dependencies to the latest versions for better performance and security.

✅ Checks

  • Added test cases for my code

Sorry, something went wrong.

@hwbrzzl hwbrzzl requested a review from a team as a code owner February 21, 2025 08:07
@hwbrzzl hwbrzzl changed the base branch from master to v1.15.x February 21, 2025 08:07
Copy link
Contributor

coderabbitai bot commented Feb 21, 2025

Walkthrough

This pull request introduces broad refactorings and enhancements across multiple components. Key changes include updating service provider registrations by removing local binding constants in favor of standardized ones from the central contracts package, renaming receiver variables for clarity, and updating test logic (e.g. using a shared timestamp in auth tests and a revised artisan flag in console applications). Schema capabilities have been extended with new methods for boolean and custom columns, and dependency versions in the module file have been updated. Additional updates include improvements to logging, ORM context handling, and mock functionalities.

Changes

File(s) Change Summary
auth/auth_test.go, console/application.go, console/application_test.go, console/cli_helper_test.go Updated tests and application constructors to use a consistent timestamp and a new boolean parameter for enabling artisan mode.
auth/service_provider.go, cache/service_provider.go, config/service_provider.go, console/service_provider.go, grpc/service_provider.go, hash/service_provider.go, http/service_provider.go, log/service_provider.go, mail/service_provider.go, queue/service_provider.go, route/service_provider.go, schedule/service_provider.go, session/service_provider.go, testing/service_provider.go, translation/service_provider.go, validation/service_provider.go, event/service_provider.go, filesystem/service_provider.go, foundation/container.go Refactored service provider registrations by removing custom binding constants and replacing them with references from the contracts package; receiver names were updated for clarity.
contracts/binding.go Introduced new binding constants for various components (e.g. config, auth, console, cache, etc.) to centralize binding definitions.
contracts/database/schema/blueprint.go, contracts/database/schema/grammar.go
database/schema/blueprint.go
database/schema/grammars/* and related tests
Enhanced schema definition support by adding methods for creating boolean and generic type columns; added tests for boolean type handling in MySQL, PostgreSQL, SQLite, and SQL Server.
database/gorm/logger.go, database/orm/orm.go Adjusted logging logic (removing an artisan-specific error level) and improved ORM context handling by better integrating HTTP context.
go.mod Updated multiple dependency versions and added new dependencies to align with current releases.
grpc/application.go Modified GRPC log output formatting and text messaging.
mocks/database/schema/Blueprint.go, mocks/database/schema/Grammar.go Added new mock methods and types to simulate Boolean and generic column creation in schema definitions.
support/collect/collect.go, support/constant.go, support/database/*, support/database/database_test.go Updated utility functions (e.g. Reverse and Shuffle) to use the mutable package, enhanced ID reflection logic in database helpers, and bumped the component version.

Sequence Diagram(s)

Console Application Artisan Flag Flow

Loading
sequenceDiagram
  participant User as User
  participant App as Console.Application
  User->>App: NewApplication(name, usage, usageText, version, useArtisan)
  Note right of App: Initializes with useArtisan flag
  App->>App: Adjust command arguments based on flag

Service Provider Binding Registration Flow

Loading
sequenceDiagram
  participant Container as Application Container
  participant SP as ServiceProvider (e.g., Auth, Cache, etc.)
  participant Contracts as Contracts Package
  Container->>SP: Call Register()
  SP->>Container: app.Singleton(contracts.BindingX, factoryFunc)
  Container-->>SP: Service bound using contract key

Possibly related PRs

  • chore: merge v1.15.3 #842: Addresses similar changes in authentication tests by standardizing the timestamp usage via a shared now variable.
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Sorry, something went wrong.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.

Actionable comments posted: 2

🧹 Nitpick comments (2)
translation/service_provider.go (1)

30-30: Consider improving context handling.

The current approach of extracting context from parameters map using type assertion (parameters["ctx"].(context.Context)) is not type-safe and could lead to runtime panics if the context is missing or of wrong type.

Consider creating a dedicated constructor or configuration method that explicitly accepts the context:

-func (translation *ServiceProvider) Register(app foundation.Application) {
+func (translation *ServiceProvider) Register(app foundation.Application) {
 	app.BindWith(contracts.BindingTranslation, func(app foundation.Application, parameters map[string]any) (any, error) {
+		ctx, ok := parameters["ctx"].(context.Context)
+		if !ok {
+			return nil, errors.New("context not provided or invalid")
+		}
 		// ... other initializations ...
-		trans := NewTranslator(parameters["ctx"].(context.Context), loader, locale, fallback, logger)
+		trans := NewTranslator(ctx, loader, locale, fallback, logger)
 		return trans, nil
 	})
}
database/schema/grammars/sqlite_test.go (1)

361-365: Consider enhancing the boolean type test coverage.

While the basic test is good, consider adding test cases for:

  • Column with default values (true/false)
  • Column with nullable constraint
    This would align with the test coverage of other data types in the suite.
 func (s *SqliteSuite) TestTypeBoolean() {
-	mockColumn := mocksschema.NewColumnDefinition(s.T())
+	tests := []struct {
+		name     string
+		setup    func(column *mocksschema.ColumnDefinition)
+		expected string
+	}{
+		{
+			name:     "basic boolean",
+			setup:    func(column *mocksschema.ColumnDefinition) {},
+			expected: "tinyint(1)",
+		},
+		{
+			name: "boolean with default true",
+			setup: func(column *mocksschema.ColumnDefinition) {
+				column.EXPECT().GetDefault().Return(true).Once()
+			},
+			expected: "tinyint(1) default true",
+		},
+		{
+			name: "nullable boolean",
+			setup: func(column *mocksschema.ColumnDefinition) {
+				column.EXPECT().GetNullable().Return(true).Once()
+			},
+			expected: "tinyint(1) null",
+		},
+	}
 
-	s.Equal("tinyint(1)", s.grammar.TypeBoolean(mockColumn))
+	for _, test := range tests {
+		s.Run(test.name, func() {
+			mockColumn := mocksschema.NewColumnDefinition(s.T())
+			test.setup(mockColumn)
+			s.Equal(test.expected, s.grammar.TypeBoolean(mockColumn))
+		})
+	}
 }
🛑 Comments failed to post (2)
console/service_provider.go (1)

19-19: 💡 Verification agent

🧩 Analysis chain

Verify the impact of the new boolean parameter.

The addition of true as the last argument to NewApplication is a breaking change. Please ensure:

  1. All existing calls to NewApplication are updated.
  2. The purpose of this boolean flag is documented.

🏁 Script executed:

#!/bin/bash
# Search for other calls to NewApplication that might need updating
rg "NewApplication\(" --type go

Length of output: 6927


Impact of the useArtisan Parameter in the Console Module

  • Verified that in the console package—including in console/service_provider.go and console/application_test.go—all calls to NewApplication have been updated to include the new boolean parameter.
  • The breaking change is isolated to the console-specific version of NewApplication (which now accepts (name, usage, usageText, version, useArtisan)); other packages use different overloads and remain unaffected.
  • Action Required: Please add documentation in console/application.go (and any relevant docs) to clearly explain the purpose and expected behavior of the new useArtisan flag.
support/collect/collect.go (1)

61-62: ⚠️ Potential issue

Breaking Change: Mutable operations in Reverse and Shuffle.

The switch from lo to lo/mutable changes the behavior of these functions:

  • They now modify the input slice in-place instead of creating a new slice
  • This is more memory efficient but could break existing code expecting immutable behavior

Consider these options:

  1. Document the mutable behavior clearly in the function comments
  2. Create new functions for mutable operations and maintain immutable versions

Apply this diff to add documentation:

 // Reverse reverses array so that the first element becomes the last, the second element becomes the second to last, and so on.
+// Note: This function modifies the input slice in-place.
 func Reverse[T any](collection []T) []T {

 // Shuffle returns an array of shuffled values. Uses the Fisher-Yates shuffle algorithm.
+// Note: This function modifies the input slice in-place.
 func Shuffle[T any](collection []T) []T {

Also applies to: 67-68

@hwbrzzl hwbrzzl closed this Feb 21, 2025
@hwbrzzl hwbrzzl reopened this Feb 21, 2025
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.50.

Benchmark suite Current: c374a38 Previous: 3cde68c Ratio
Benchmark_EncryptString 6656 ns/op 2160 B/op 15 allocs/op 2225 ns/op 2160 B/op 15 allocs/op 2.99
Benchmark_EncryptString - ns/op 6656 ns/op 2225 ns/op 2.99
Benchmark_DecryptString 7517 ns/op 2040 B/op 17 allocs/op 2045 ns/op 2040 B/op 17 allocs/op 3.68
Benchmark_DecryptString - ns/op 7517 ns/op 2045 ns/op 3.68

This comment was automatically generated by workflow using github-action-benchmark.

Copy link

codecov bot commented Feb 21, 2025

Codecov Report

Attention: Patch coverage is 87.50000% with 1 line in your changes missing coverage. Please review.

Please upload report for BASE (v1.15.x@01b1b9d). Learn more about missing BASE report.

Files with missing lines Patch % Lines
support/database/database.go 87.50% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             v1.15.x     #903   +/-   ##
==========================================
  Coverage           ?   68.62%           
==========================================
  Files              ?      218           
  Lines              ?    18882           
  Branches           ?        0           
==========================================
  Hits               ?    12957           
  Misses             ?     5256           
  Partials           ?      669           

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

@hwbrzzl hwbrzzl merged commit 05a7f44 into v1.15.x Feb 21, 2025
11 of 12 checks passed
@hwbrzzl hwbrzzl deleted the bowen/fix-get-id branch February 21, 2025 09:07
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.

None yet

1 participant