go-gorm / postgres

GORM PostgreSQL driver
MIT License
228 stars 120 forks source link

Fix regex for empty string as default for varchar and text types #201

Closed kalistratovtimofey closed 11 months ago

kalistratovtimofey commented 1 year ago

What did this pull request do?

Fix regex to properly cut default value for default empty string and default whitespace

User Case Description

I've faced extra "ALTER TABLE..." requests on every app start with Gorm auto-migrate. Investigated that Gorm doesn't cut properly "default" value, if it is empty string or whitespace. Returned to case with 2 separate regexes that was first added in https://github.com/go-gorm/postgres/pull/143#discussion_r1056736772