Code Monkey home page Code Monkey logo

Comments (3)

hsluoyz avatar hsluoyz commented on May 18, 2024

Hi @HaoweiCh , it seems that Gorm's DropTable() fails to delete the table for MariaDB, maybe the SQL syntax is wrong for MariaDB. Can you provide a runnable example and your MariaDB version? So I can install the MariaDB and run your code to debug it.

gorm-adapter/adapter.go

Lines 162 to 167 in e74a050

func (a *Adapter) dropTable() {
err := a.db.DropTable(&CasbinRule{}).Error
if err != nil {
panic(err)
}
}

from gorm-adapter.

HaoweiCh avatar HaoweiCh commented on May 18, 2024
func init() {
	DB = Connect(
		"123.106.169.37:3306",
		"p",
		"spiders",
	).Set("gorm:table_options", "CHARSET=utf8")
}

func Connect(hostAndPort, userNameAndPassword, databaseName string) (db *gorm.DB) {
	var err error
	if db, err = gorm.Open("mysql",
		fmt.Sprintf("%s@tcp(%s)/%s?charset=utf8mb4&collation=utf8mb4_unicode_ci&parseTime=true&loc=Local",
			userNameAndPassword, hostAndPort, databaseName)); err != nil {
		panic(err)
	}
	return
}

I guess .Set("gorm:table_options", "CHARSET=utf8") may cause this problem. but even remove it problem exists

10.3.13-MariaDB

if this info cannot help, I'll try provide more.

Even when this err issued, the data 've already wrote into database,,

from gorm-adapter.

hsluoyz avatar hsluoyz commented on May 18, 2024

This is not an issue of this repo. You should ask in in Gorm's issue tracker.

from gorm-adapter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.