go-gorm / go-gorm/postgres

How to use NamingStrategy.IdentifierMaxLength in postgres driver

Open
#191 3 comments 0 reactions 1 assignee Assigned to @alidevhere View on GitHub
Dominant language
Go
Stars
297
Forks
155
Avg merge
27m
Merged PRs (30d)
2

Description

## 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](https://github.com/go-gorm/gorm/commit/26663ab9bf55c603ca69a97504a1dfe7d53a1bb3)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.