Skip to content

Fix: remove hard dependency on gorm.io/driver/mysql#328

Open
dannyota wants to merge 1 commit into
go-gorm:masterfrom
dannyota:json-remove-mysql-hard-dep
Open

Fix: remove hard dependency on gorm.io/driver/mysql#328
dannyota wants to merge 1 commit into
go-gorm:masterfrom
dannyota:json-remove-mysql-hard-dep

Conversation

@dannyota
Copy link
Copy Markdown
Contributor

  • Do only one thing
  • Non breaking API changes
  • Tested

What did this pull request do?

Replace *mysql.Dialector type assertions with reflection-based isMariaDB() helper to read ServerVersion. Removes gorm.io/driver/mysql import from json.go, json_map.go, json_type.go.

Fixes #160

User Case Description

Consumers of gorm.io/datatypes transitively pull in gorm.io/driver/mysql even if they only use PostgreSQL or SQLite. After this change, all driver dependencies are test-only.

Replaces #321. The original PR could not be reopened after its source fork was deleted.

Replace direct *mysql.Dialector type assertions with a reflection-based
isMariaDB() helper to read the ServerVersion field. This removes the
compile-time dependency on gorm.io/driver/mysql from production code,
so library consumers no longer transitively pull in the MySQL driver.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

Exclude Unused Imports

1 participant