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

add USING ?::? to AlterColumn #105

Merged
merged 2 commits into from Oct 8, 2022

Conversation

warren830
Copy link
Contributor

What did this pull request do?

Add USING ?::? to AlterColumn
Without this, it will report error as I described in the issue #104

User Case Description

We used migrator to change column data type

Copy link
Member

@a631807682 a631807682 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM if column without default value.
Maybe we need to add conditions, use Using when no implicit (automatic) cast and change the defalut value

@warren830
Copy link
Contributor Author

LGTM if column without default value. Maybe we need to add conditions, use Using when no implicit (automatic) cast and change the defalut value

Sounds great, I will modify it and submit again

@warren830
Copy link
Contributor Author

I did some shallow research, it's hard to add conditions. Cause there are too many data types.
time <-> varchar,
int <-> varchar
longtext <-> int, varchar
and so on

@a631807682
Copy link
Member

I don't know whether Using has side effects. If not, we can drop default value first when type changes and add it after completion. We can also judge whether to execute the above process through the error code.

@warren830
Copy link
Contributor Author

I don't know whether Using has side effects. If not, we can drop default value first when type changes and add it after completion. We can also judge whether to execute the above process through the error code.

It's a better way to execute the above process according to the error code. If it's ok, I can do it

@Gilwe
Copy link

Gilwe commented Sep 12, 2022

it is still broken.
if the column is of part of the partition definition you'll get ERROR: cannot alter type of column named in partition key (SQLSTATE 42P16)

@jinzhu jinzhu merged commit a4858c5 into go-gorm:master Oct 8, 2022
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

Successfully merging this pull request may close these issues.

None yet

4 participants