Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use NamingStrategy.IdentifierMaxLength in postgres driver #191

Open
alidevhere opened this issue May 30, 2023 · 3 comments
Open

How to use NamingStrategy.IdentifierMaxLength in postgres driver #191

alidevhere opened this issue May 30, 2023 · 3 comments
Assignees

Comments

@alidevhere
Copy link
Contributor

alidevhere commented May 30, 2023

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

@a631807682
Copy link
Member

@a631807682 a631807682 assigned alidevhere and unassigned jinzhu May 31, 2023
@alidevhere
Copy link
Contributor Author

@jinzhu @a631807682
pull request is created for this issue

@alidevhere
Copy link
Contributor Author

@jinzhu @a631807682

PR created for this issue

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

No branches or pull requests

3 participants