Skip to content

How to use NamingStrategy.IdentifierMaxLength in postgres driver #191

Open
@alidevhere

Description

@alidevhere

Describe the feature

NamingStrategy.IdentifierMaxLength has been added in gorm, which allows to override max length of 64. How to make use of this in postgres driver to change it to 63.
@jinzhu
i can only think of it like this :

import (
	"gorm.io/driver/postgres"
	"gorm.io/gorm"
	s "gorm.io/gorm/schema"
)

func main() {

	db, err := gorm.Open(postgres.New(postgres.Config{
		DSN:                  "host=localhost user=gorm password=gorm dbname=gorm port=9920 sslmode=disable TimeZone=Asia/Shanghai", // data source name, refer https://github.com/jackc/pgx
		PreferSimpleProtocol: true,                                                                                                  // disables implicit prepared statement usage. By default pgx automatically uses the extended protocol
	}), &gorm.Config{NamingStrategy: s.NamingStrategy{IdentifierMaxLength: 63}})

}


Related Issues

And please assign this issue to me, i will work on it
commited change in gorm

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions