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

fail to alter existing boolean column from smallint with default value to boolean in postgres #180

Open
jeffry-luqman opened this issue May 9, 2023 · 0 comments
Assignees

Comments

@jeffry-luqman
Copy link
Contributor

GORM Playground Link

go-gorm/playground#595

Description

If we want to change boolean column from smallint with default value to boolean, it will report error like below:

2023/05/09 15:56:04 /home/ubuntu/temp/gorm-playground/main_test.go:41 ERROR: default for column "boolean_column" cannot be cast automatically to type boolean (SQLSTATE 42804)
[0.654ms] [rows:0] ALTER TABLE "column_structs" ALTER COLUMN "boolean_column" TYPE boolean USING "boolean_column"::INT::boolean

We only need to drop existing default value in func AlterColumn in postgres@v1.5.0/migrator.go

jeffry-luqman added a commit to jeffry-luqman/gorm-postgres that referenced this issue May 9, 2023
jinzhu pushed a commit that referenced this issue May 28, 2023
…t value to boolean in postgres (#180) (#181)

* fix : fail to alter column from smallint to boolean

* fix : fail to alter column from smallint to boolean

* fix : fail to alter column from string to boolean

* fix : fail to alter column from string to boolean if the value is "false" in string

* move using conversion expression to func

* move using expression to func

* fix : fail to alter existing boolean column from smallint with default value to boolean in postgres (#180)

* isUncastableDefaultValue

* ModifyColumn & DropDefaultValue

* ModifyColumn + DropDefaultValue > modifyColumn
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

2 participants