When I use the JSON type in MySQL,select data from JSON fields,Return prompt “Error 1815 (HY000): [9001, 2024071810515419216812725203453810909] Unsupported column type: 245“

CREATE TABLE t_jsons ( id bigint AUTO_INCREMENT, tag json, aaa varchar(255), obj json, PRIMARY KEY (id) ) ;

INSERT INTO t_jsons (id, tag, aaa, obj) VALUES (2, '[\"dd\",\"ccc\"]', 'adssd', '{\"name\":\"李四\"}'); INSERT INTO t_jsons (id, tag, aaa, obj) VALUES (1, '[\"aaa\",\"bbb\"]', 'ttt', '{\"name\":\"张三\"}');

package main

import ( "database/sql/driver" "encoding/json" "fmt" "gorm.io/driver/mysql" "gorm.io/gorm" )

type Tag []string

type User struct { Name string Tag Tag gorm:"type:string" Obj string gorm:"type:string" }

func (i Tag) Scan(value interface{}) error { v, _ := value.([]byte) var receiver Tag err := json.Unmarshal(v, &receiver) if err != nil { return err } i = receiver return nil }

func (i Tag) Value() (driver.Value, error) { return json.Marshal(i) }

func main() { dsn := "root:password@tcp(ip:point)/db?charset=utf8mb4&parseTime=True&loc=Local" db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{}) if err != nil { panic(err) } var users []User db.Table("t_jsons").Where(JSON_EXTRACT(obj, '$.name') = ?, "name").Debug().Scan(&users) fmt.Printf("result: %+v", users) }

Comment From: github-actions[bot]

The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking