Skip to content

feat: add base entity#2

Merged
itsLeonB merged 2 commits into
mainfrom
dev
Sep 3, 2025
Merged

feat: add base entity#2
itsLeonB merged 2 commits into
mainfrom
dev

Conversation

@itsLeonB

@itsLeonB itsLeonB commented Sep 2, 2025

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added a reusable base entity with common CRUD fields and helper methods.
  • Refactor

    • Renamed the library package to “crud” to streamline imports and usage.
  • Documentation

    • Greatly expanded the README with badges, features, installation, architecture, examples, transactions, query scopes, security, testing, configuration, performance tips, and contribution guidance.
  • Chores

    • Promoted UUID dependency to direct requirement; updated a utility dependency version.
  • Tests

    • Updated tests to match a relocated constant string representation.

@coderabbitai

coderabbitai Bot commented Sep 2, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

Adds a new BaseEntity type with common CRUD fields and helper methods; renames package from ezutil to crud across several files; promotes github.com/google/uuid to a direct dependency; updates a constant value and its tests; and replaces README with a full project documentation. No functional logic changes beyond API namespace/constant value edits.

Changes

Cohort / File(s) Summary
Documentation
README.md
Replaces a short placeholder with a comprehensive multi-section README (badges, features, installation, architecture, examples, testing, contribution, license, etc.).
New entity foundation
base_entity.go
Adds exported BaseEntity struct (ID uuid.UUID, CreatedAt time.Time, UpdatedAt time.Time, DeletedAt sql.NullTime) and methods IsZero() and IsDeleted(); imports database/sql, time, and github.com/google/uuid.
Package rename: ezutil → crud
gorm_crud_repository.go, gorm_scopes.go, gorm_transactor.go
Changes package declaration to package crud (removes a TODO comment); code, signatures, and logic unchanged but package namespace updated for consumers.
Constant & tests
lib/constants.go, test/constants_test.go
Updates exported constant value ContextKeyGormTx from "ezutil.gormTx""go-crud.gormTx" and adjusts test expectations accordingly (minor formatting tweaks in tests).
Dependency update
go.mod
Promotes github.com/google/uuid to a direct dependency (v1.6.0) and updates github.com/itsLeonB/ezutil/v2 version to v2.0.0 in the direct require block.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • initial pkg #1 — Initial package/setup PR that introduced the same CRUD components and is directly related to the package renames and BaseEntity additions.

Poem

I thump my paws: a base appears at dawn,
UUID seeds and timestamps neatly sown.
From ezutil burrow to crud I hop,
Docs unfurl wide — the rabbit won’t stop.
Tests tick green; I nibble a carrot, gone. 🥕

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dev

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit 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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 10

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
gorm_transactor.go (1)

23-33: Update package import paths and document migration for v2

  • Replace all references to github.com/itsLeonB/ezutil/v2 (gorm_scopes.go, go.mod, lib/constants.go, test/constants_test.go, README.md examples) with the new module path github.com/itsLeonB/crud/v2
  • Add a “Migration” section in README detailing import-path and alias changes for consumers
  • Cut a new major (v2) release to signal this breaking change
🧹 Nitpick comments (12)
gorm_scopes.go (3)

17-26: Guard against limit <= 0 to avoid empty result sets.

GORM treats Limit(0) as “return 0 rows”. Skip pagination when limit <= 0.

Apply:

 func Paginate(page, limit int) func(db *gorm.DB) *gorm.DB {
   return func(db *gorm.DB) *gorm.DB {
     if page < 1 {
       page = 1
     }
+    if limit <= 0 {
+      return db
+    }
 
     offset := (page - 1) * limit
 
     return db.Limit(limit).Offset(offset)
   }
 }

32-47: Prefer clause.OrderByColumn to avoid manual SQL strings.

Safer and handles identifiers better. Keep your field-name validation as-is.

Apply:

 func OrderBy(field string, ascending bool) func(db *gorm.DB) *gorm.DB {
   return func(db *gorm.DB) *gorm.DB {
     // Basic validation to prevent SQL injection
     // Only allow alphanumeric characters, underscores, and dots for table.column
     if !internal.IsValidFieldName(field) {
       _ = db.AddError(eris.Errorf("invalid field name: %s", field))
       return db
     }
-
-    if ascending {
-      return db.Order(field + " ASC")
-    }
-
-    return db.Order(field + " DESC")
+    col := clause.Column{Name: field}
+    // Optional: split "table.column" if provided
+    if i := strings.IndexByte(field, '.'); i > 0 && i < len(field)-1 {
+      col = clause.Column{Table: field[:i], Name: field[i+1:]}
+    }
+    return db.Order(clause.OrderByColumn{Column: col, Desc: !ascending})
   }
 }

Add import:

 import (
   "reflect"
   "time"
+  "strings"

92-96: Make default order safer across models.

If a model lacks created_at, the query errors. Consider parameterizing or using clause.OrderByColumn.

Apply:

 func DefaultOrder() func(*gorm.DB) *gorm.DB {
   return func(db *gorm.DB) *gorm.DB {
-    return db.Order("created_at DESC")
+    return db.Order(clause.OrderByColumn{Column: clause.Column{Name: "created_at"}, Desc: true})
   }
 }
gorm_crud_repository.go (3)

42-47: Runtime type check: restrict T to struct types.

Prevents accidental use with slices/maps/etc., which GORM won’t handle as intended.

Apply:

 func NewCRUDRepository[T any](db *gorm.DB) CRUDRepository[T] {
   var zero T
-  if reflect.TypeOf(zero).Kind() == reflect.Ptr {
+  t := reflect.TypeOf(zero)
+  if t.Kind() == reflect.Ptr {
     panic("CRUDRepository does not support pointer types for T")
   }
+  if t.Kind() != reflect.Struct {
+    panic("CRUDRepository requires T to be a struct type")
+  }
   return &crudRepositoryGorm[T]{db}
 }

159-174: Large batch inserts: consider chunking to avoid parameter/packet limits.

Use CreateInBatches with a sensible batch size (e.g., 200–1000).

Apply:

- if err = db.Create(&models).Error; err != nil {
+ if err = db.CreateInBatches(&models, 500).Error; err != nil {

176-182: Simplify zero-value check.

Use reflect.Value.IsZero(), which is clearer and avoids allocation.

Apply:

 func (cr *crudRepositoryGorm[T]) checkZeroValue(model T) error {
-  if reflect.DeepEqual(model, *new(T)) {
+  if reflect.ValueOf(model).IsZero() {
     return eris.New("model cannot be zero value")
   }
 
   return nil
 }
base_entity.go (2)

12-13: Timestamp tags: either rely on GORM conventions or declare both explicitly

Optional: add autoCreateTime to CreatedAt for clarity, or drop the explicit tag on UpdatedAt to rely on naming conventions.

-	CreatedAt time.Time
-	UpdatedAt time.Time `gorm:"autoUpdateTime"`
+	CreatedAt time.Time `gorm:"autoCreateTime"`
+	UpdatedAt time.Time `gorm:"autoUpdateTime"`

10-15: Consider JSON tags for API serialization

Improves DTO stability when exposed via HTTP.

-	ID        uuid.UUID `gorm:"type:uuid;primaryKey"`
-	CreatedAt time.Time `gorm:"autoCreateTime"`
-	UpdatedAt time.Time `gorm:"autoUpdateTime"`
-	DeletedAt gorm.DeletedAt `gorm:"index"`
+	ID        uuid.UUID      `json:"id"         gorm:"type:uuid;primaryKey"`
+	CreatedAt time.Time      `json:"createdAt"  gorm:"autoCreateTime"`
+	UpdatedAt time.Time      `json:"updatedAt"  gorm:"autoUpdateTime"`
+	DeletedAt gorm.DeletedAt `json:"deletedAt"  gorm:"index"`
README.md (4)

51-59: Showcase BaseEntity in the sample model (optional but recommended)

Aligns docs with the new BaseEntity and encourages UUID usage.

-type User struct {
-    ID        uint      `gorm:"primaryKey"`
-    Name      string    `gorm:"not null"`
-    Email     string    `gorm:"unique"`
-    Age       int
-    CreatedAt time.Time
-    UpdatedAt time.Time
-}
+type User struct {
+    crud.BaseEntity
+    Name  string `gorm:"not null"`
+    Email string `gorm:"unique"`
+    Age   int
+}

388-405: Add language to fenced code block (markdownlint MD040)

Specify a language for the project structure block.

-```
+```text
 go-crud/
 ├── gorm_crud_repository.go    # Main CRUD repository implementation
 ...

---

`409-423`: **Call out Postgres extension requirement if keeping DB-side UUID default**

If you retain default:gen_random_uuid(), add a short note showing CREATE EXTENSION IF NOT EXISTS pgcrypto; and clarify alternatives for MySQL/SQLite. Otherwise, the proposed hook in BaseEntity removes this requirement.

---

`517-517`: **Avoid emphasis-as-heading (markdownlint MD036)**

Use a heading style instead of bold-only.


```diff
-**Built with ❤️ for the Go community**
+### Built with ❤️ for the Go community
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d684744 and 99745f0.

📒 Files selected for processing (6)
  • README.md (1 hunks)
  • base_entity.go (1 hunks)
  • go.mod (1 hunks)
  • gorm_crud_repository.go (1 hunks)
  • gorm_scopes.go (1 hunks)
  • gorm_transactor.go (1 hunks)
🧰 Additional context used
🪛 LanguageTool
README.md

[grammar] ~9-~9: There might be a mistake here.
Context: ...nsive security features. ## 🚀 Features - 🔒 Type-Safe Operations: Generic inter...

(QB_NEW_EN)


[grammar] ~11-~11: There might be a mistake here.
Context: ... interfaces for compile-time type safety - 📊 Transaction Management: Context-awa...

(QB_NEW_EN)


[grammar] ~12-~12: There might be a mistake here.
Context: ...t-aware transactions with nested support - 🔍 Query Scopes: Reusable query builde...

(QB_NEW_EN)


[grammar] ~13-~13: There might be a mistake here.
Context: ... for pagination, filtering, and ordering - 🛡️ Security First: SQL injection prev...

(QB_NEW_EN)


[grammar] ~14-~14: There might be a mistake here.
Context: ...ion prevention and field name validation - ⚡ Performance: Optimized queries with ...

(QB_NEW_EN)


[grammar] ~15-~15: There might be a mistake here.
Context: ...ies with preloading and batch operations - 🧪 Well Tested: 84.3% test coverage wi...

(QB_NEW_EN)


[grammar] ~16-~16: There might be a mistake here.
Context: ...t coverage with comprehensive test suite - 📖 Clean API: Intuitive interfaces fol...

(QB_NEW_EN)


[grammar] ~17-~17: There might be a mistake here.
Context: ...e interfaces following Go best practices ## 📦 Installation ```bash go get github.c...

(QB_NEW_EN)


[grammar] ~19-~19: There might be a mistake here.
Context: ...ng Go best practices ## 📦 Installation bash go get github.com/itsLeonB/go-crud ## 🏗️ Architecture The library is built a...

(QB_NEW_EN)


[grammar] ~25-~25: There might be a mistake here.
Context: ...tsLeonB/go-crud ``` ## 🏗️ Architecture The library is built around three core c...

(QB_NEW_EN)


[grammar] ~35-~35: There might be a mistake here.
Context: ...usable query builders ## 🔧 Quick Start ### Basic Setup ```go package main import ...

(QB_NEW_EN)


[grammar] ~81-~81: There might be a mistake here.
Context: ...gic here... } ``` ## 📚 Core Components ### CRUDRepository Interface The `CRUDRepos...

(QB_NEW_EN)


[grammar] ~111-~111: There might be a mistake here.
Context: .... FOR UPDATE } ## 💡 Usage Examples ### Basic CRUD Operations go ctx := cont...

(QB_NEW_EN)


[grammar] ~194-~194: There might be a mistake here.
Context: ... spec) ## 🔄 Transaction Management ### Basic Transactions go transactor := ...

(QB_NEW_EN)


[grammar] ~266-~266: There might be a mistake here.
Context: ... user) }) }) ``` ## 🔍 Query Scopes The library provides powerful query scop...

(QB_NEW_EN)


[grammar] ~331-~331: There might be a mistake here.
Context: ...nd(&users) ``` ## 🛡️ Security Features ### SQL Injection Prevention The library in...

(QB_NEW_EN)


[grammar] ~360-~360: There might be a mistake here.
Context: ...haracters or SQL keywords ## 🧪 Testing The library comes with comprehensive tes...

(QB_NEW_EN)


[grammar] ~380-~380: There might be a mistake here.
Context: ...ests**: All public functions and methods - Integration Tests: Database operations...

(QB_NEW_EN)


[grammar] ~381-~381: There might be a mistake here.
Context: ...Tests**: Database operations with SQLite - Security Tests: SQL injection preventi...

(QB_NEW_EN)


[grammar] ~382-~382: There might be a mistake here.
Context: ...curity Tests**: SQL injection prevention - Concurrency Tests: Thread safety valid...

(QB_NEW_EN)


[grammar] ~383-~383: There might be a mistake here.
Context: ...rrency Tests**: Thread safety validation - Performance Tests: Benchmarks for crit...

(QB_NEW_EN)


[grammar] ~386-~386: There might be a mistake here.
Context: ...tical functions ## 📁 Project Structure go-crud/ ├── gorm_crud_repository.go # Main CRUD repository implementation ├── gorm_scopes.go # Query scopes and builders ├── gorm_transactor.go # Transaction management ├── internal/ │ ├── gorm.go # Internal GORM utilities │ └── transactor.go # Internal transaction logic ├── lib/ │ └── constants.go # Library constants └── test/ # Comprehensive test suite ├── crud_repository_test.go ├── scopes_test.go ├── transactor_test.go ├── internal_test.go ├── constants_test.go └── run_tests.sh ## 🔧 Configuration ### Database Drivers ...

(QB_NEW_EN)


[grammar] ~407-~407: There might be a mistake here.
Context: ...── run_tests.sh ``` ## 🔧 Configuration ### Database Drivers The library works with...

(QB_NEW_EN)


[grammar] ~436-~436: There might be a mistake here.
Context: ...e, }, }) ## 🚀 Performance Tips ### 1. Use Batch Operations go // Instea...

(QB_NEW_EN)


[grammar] ~472-~472: There might be a mistake here.
Context: ... return nil }) ``` ## 🤝 Contributing Contributions are welcome! Please ensure...

(QB_NEW_EN)


[grammar] ~499-~499: There might be a mistake here.
Context: ...ke test-coverage-html ``` ## 📄 License This project is licensed under the MIT L...

(QB_NEW_EN)


[grammar] ~503-~503: There might be a mistake here.
Context: ...file for details. ## 🙏 Acknowledgments - GORM: The fantastic ORM library that p...

(QB_NEW_EN)


[grammar] ~505-~505: There might be a mistake here.
Context: ...tic ORM library that powers this project - Testify: For making tests more readabl...

(QB_NEW_EN)


[grammar] ~506-~506: There might be a mistake here.
Context: ...ing tests more readable and maintainable - Eris: For enhanced error handling and ...

(QB_NEW_EN)


[grammar] ~509-~509: There might be a mistake here.
Context: ...handling and stack traces ## 📞 Support - Issues: [GitHub Issues](https://github...

(QB_NEW_EN)

🪛 markdownlint-cli2 (0.17.2)
README.md

388-388: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


517-517: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

🪛 GitHub Actions: CI
README.md

[error] 1-1: Tar extraction failed during cache restore. Command: '/usr/bin/tar -xf /home/runner/work/_temp/a133bc0b-2e19-45e9-9568-7a19f98e8f7e/cache.tzst -P -C /home/runner/work/go-crud/go-crud --use-compress-program unzstd'; Error: Cannot open: File exists.

🔇 Additional comments (7)
go.mod (1)

6-6: Direct dependency promotion for uuid looks good.

Using github.com/google/uuid directly matches BaseEntity usage. No concerns.

gorm_scopes.go (1)

1-1: Package rename to crud — LGTM.

Consistent with the repo-wide namespace.

gorm_crud_repository.go (3)

1-1: Package rename to crud — LGTM.

Interface and behavior unchanged.


96-121: API behavior: zero-value return on not found.

FindFirst returns (zero T, nil) for not-found. Confirm callers expect “no row” without error; otherwise propagate gorm.ErrRecordNotFound or return (T, bool, error).


152-154: Hard deletes by default — verify intent.

Unscoped().Delete performs physical deletes, bypassing soft-delete fields. Confirm this is desired across all entities.

gorm_transactor.go (1)

1-1: LGTM: package rename to crud

No functional changes; interfaces and behavior preserved.

README.md (1)

228-246: Replace ezutil references with crud in README examples

  • Update imports and instantiations:
    import ".../crud" instead of ".../ezutil"
    userRepo := crud.NewCRUDRepository[User](db)
    transactor := crud.NewTransactor(db)
  • In manual and nested transaction snippets, the calls to transactor.Begin, transactor.Commit, and transactor.WithinTransaction remain, but ensure they use the crud package transactor.
  • Replace every ezutil.* occurrence (Specification, Paginate, OrderBy, DefaultOrder, WhereBySpec, BetweenTime, PreloadRelations, ForUpdate, etc.) with the corresponding crud.* call throughout README.md.

Likely an incorrect or invalid review comment.

Comment thread base_entity.go
Comment thread base_entity.go
Comment thread go.mod
Comment thread README.md
Comment thread README.md
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md Outdated
Comment thread README.md

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

♻️ Duplicate comments (2)
go.mod (1)

3-4: Fix go directive format (and optional toolchain pin) to unblock CI cache issue

Go requires major.minor in the go directive. The current "go 1.25.0" also matches the failing cache path in CI. Use "go 1.25" and (optionally) add a separate toolchain directive.

Apply:

-go 1.25.0
+go 1.25
+toolchain go1.25.0

Then verify locally/CI:

  • go env GOVERSION
  • go mod tidy
  • rerun the workflow to confirm cache restore no longer errors.
README.md (1)

42-49: Quick Start import is missing time (example won’t compile)

User model uses time.Time.

Apply:

 import (
     "context"
     "log"
+    "time"

     "github.com/itsLeonB/go-crud"
     "gorm.io/driver/postgres"
     "gorm.io/gorm"
 )
🧹 Nitpick comments (4)
test/constants_test.go (2)

55-57: Minor type tidy: prefer any over interface{}

Not required, but using any is the idiomatic alias in modern Go.

Apply:

-constaints := map[string]interface{}{
+constaints := map[string]any{

73-79: Nit: remove stray blank lines to tighten the test

Purely cosmetic.

README.md (2)

388-406: Add language to fenced block to satisfy markdownlint (MD040)

Use a neutral language for the directory tree.

Apply:

-```
+```text
 go-crud/
 ├── gorm_crud_repository.go    # Main CRUD repository implementation
 ├── gorm_scopes.go            # Query scopes and builders
 ├── gorm_transactor.go        # Transaction management
 ├── internal/
 │   ├── gorm.go              # Internal GORM utilities
 │   └── transactor.go        # Internal transaction logic
 ├── lib/
 │   └── constants.go         # Library constants
 └── test/                    # Comprehensive test suite
     ├── crud_repository_test.go
     ├── scopes_test.go
     ├── transactor_test.go
     ├── internal_test.go
     ├── constants_test.go
     └── run_tests.sh

---

`517-517`: **Markdown style nit: avoid emphasis-as-heading (MD036)**

Optional: convert to a proper heading.

Apply:

```diff
-**Built with ❤️ for the Go community**
+### Built with ❤️ for the Go community
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 99745f0 and 51731a9.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (4)
  • README.md (1 hunks)
  • go.mod (1 hunks)
  • lib/constants.go (1 hunks)
  • test/constants_test.go (5 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
test/constants_test.go (1)
lib/constants.go (1)
  • ContextKeyGormTx (6-6)
🪛 LanguageTool
README.md

[grammar] ~9-~9: There might be a mistake here.
Context: ...nsive security features. ## 🚀 Features - 🔒 Type-Safe Operations: Generic inter...

(QB_NEW_EN)


[grammar] ~11-~11: There might be a mistake here.
Context: ... interfaces for compile-time type safety - 📊 Transaction Management: Context-awa...

(QB_NEW_EN)


[grammar] ~12-~12: There might be a mistake here.
Context: ...t-aware transactions with nested support - 🔍 Query Scopes: Reusable query builde...

(QB_NEW_EN)


[grammar] ~13-~13: There might be a mistake here.
Context: ... for pagination, filtering, and ordering - 🛡️ Security First: SQL injection prev...

(QB_NEW_EN)


[grammar] ~14-~14: There might be a mistake here.
Context: ...ion prevention and field name validation - ⚡ Performance: Optimized queries with ...

(QB_NEW_EN)


[grammar] ~15-~15: There might be a mistake here.
Context: ...ies with preloading and batch operations - 🧪 Well Tested: 84.3% test coverage wi...

(QB_NEW_EN)


[grammar] ~16-~16: There might be a mistake here.
Context: ...t coverage with comprehensive test suite - 📖 Clean API: Intuitive interfaces fol...

(QB_NEW_EN)


[grammar] ~17-~17: There might be a mistake here.
Context: ...e interfaces following Go best practices ## 📦 Installation ```bash go get github.c...

(QB_NEW_EN)


[grammar] ~19-~19: There might be a mistake here.
Context: ...ng Go best practices ## 📦 Installation bash go get github.com/itsLeonB/go-crud ## 🏗️ Architecture The library is built a...

(QB_NEW_EN)


[grammar] ~25-~25: There might be a mistake here.
Context: ...tsLeonB/go-crud ``` ## 🏗️ Architecture The library is built around three core c...

(QB_NEW_EN)


[grammar] ~35-~35: There might be a mistake here.
Context: ...usable query builders ## 🔧 Quick Start ### Basic Setup ```go package main import ...

(QB_NEW_EN)


[grammar] ~81-~81: There might be a mistake here.
Context: ...gic here... } ``` ## 📚 Core Components ### CRUDRepository Interface The `CRUDRepos...

(QB_NEW_EN)


[grammar] ~111-~111: There might be a mistake here.
Context: .... FOR UPDATE } ## 💡 Usage Examples ### Basic CRUD Operations go ctx := cont...

(QB_NEW_EN)


[grammar] ~194-~194: There might be a mistake here.
Context: ... spec) ## 🔄 Transaction Management ### Basic Transactions go transactor := ...

(QB_NEW_EN)


[grammar] ~266-~266: There might be a mistake here.
Context: ... user) }) }) ``` ## 🔍 Query Scopes The library provides powerful query scop...

(QB_NEW_EN)


[grammar] ~331-~331: There might be a mistake here.
Context: ...nd(&users) ``` ## 🛡️ Security Features ### SQL Injection Prevention The library in...

(QB_NEW_EN)


[grammar] ~360-~360: There might be a mistake here.
Context: ...haracters or SQL keywords ## 🧪 Testing The library comes with comprehensive tes...

(QB_NEW_EN)


[grammar] ~380-~380: There might be a mistake here.
Context: ...ests**: All public functions and methods - Integration Tests: Database operations...

(QB_NEW_EN)


[grammar] ~381-~381: There might be a mistake here.
Context: ...Tests**: Database operations with SQLite - Security Tests: SQL injection preventi...

(QB_NEW_EN)


[grammar] ~382-~382: There might be a mistake here.
Context: ...curity Tests**: SQL injection prevention - Concurrency Tests: Thread safety valid...

(QB_NEW_EN)


[grammar] ~383-~383: There might be a mistake here.
Context: ...rrency Tests**: Thread safety validation - Performance Tests: Benchmarks for crit...

(QB_NEW_EN)


[grammar] ~386-~386: There might be a mistake here.
Context: ...tical functions ## 📁 Project Structure go-crud/ ├── gorm_crud_repository.go # Main CRUD repository implementation ├── gorm_scopes.go # Query scopes and builders ├── gorm_transactor.go # Transaction management ├── internal/ │ ├── gorm.go # Internal GORM utilities │ └── transactor.go # Internal transaction logic ├── lib/ │ └── constants.go # Library constants └── test/ # Comprehensive test suite ├── crud_repository_test.go ├── scopes_test.go ├── transactor_test.go ├── internal_test.go ├── constants_test.go └── run_tests.sh ## 🔧 Configuration ### Database Drivers ...

(QB_NEW_EN)


[grammar] ~407-~407: There might be a mistake here.
Context: ...── run_tests.sh ``` ## 🔧 Configuration ### Database Drivers The library works with...

(QB_NEW_EN)


[grammar] ~436-~436: There might be a mistake here.
Context: ...e, }, }) ## 🚀 Performance Tips ### 1. Use Batch Operations go // Instea...

(QB_NEW_EN)


[grammar] ~472-~472: There might be a mistake here.
Context: ... return nil }) ``` ## 🤝 Contributing Contributions are welcome! Please ensure...

(QB_NEW_EN)


[grammar] ~499-~499: There might be a mistake here.
Context: ...ke test-coverage-html ``` ## 📄 License This project is licensed under the MIT L...

(QB_NEW_EN)


[grammar] ~503-~503: There might be a mistake here.
Context: ...file for details. ## 🙏 Acknowledgments - GORM: The fantastic ORM library that p...

(QB_NEW_EN)


[grammar] ~505-~505: There might be a mistake here.
Context: ...tic ORM library that powers this project - Testify: For making tests more readabl...

(QB_NEW_EN)


[grammar] ~506-~506: There might be a mistake here.
Context: ...ing tests more readable and maintainable - Eris: For enhanced error handling and ...

(QB_NEW_EN)


[grammar] ~509-~509: There might be a mistake here.
Context: ...handling and stack traces ## 📞 Support - Issues: [GitHub Issues](https://github...

(QB_NEW_EN)

🪛 markdownlint-cli2 (0.17.2)
README.md

388-388: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


517-517: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

🪛 GitHub Actions: CI
README.md

[error] 1-1: Cache extraction failed: 'tar -xf' on cache.tzst returned 'Cannot open: File exists' while restoring go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.0.linux-amd64/README.md from cache.

🔇 Additional comments (5)
lib/constants.go (1)

6-6: LGTM: context key prefix updated to match module rename

Value change to "go-crud.gormTx" is consistent with the package rename; custom key type remains safe for context usage.

test/constants_test.go (3)

19-20: LGTM: updated expected key string

Expectation now matches lib.ContextKeyGormTx’s new value.


39-40: LGTM: type assertion check remains correct

Verifies string value without losing the custom key type.


85-90: LGTM: simple ASCII guard for error msg

Checks are fine and readable.

go.mod (1)

6-8: LGTM: uuid promoted to direct dep; ezutil pinned to v2.0.0

Consistent with new BaseEntity usage and repo rename.

Comment thread README.md
Comment thread README.md
@itsLeonB itsLeonB merged commit 205614d into main Sep 3, 2025
18 checks passed
@coderabbitai coderabbitai Bot mentioned this pull request Jan 4, 2026
Merged
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.

1 participant