sqlc icon indicating copy to clipboard operation
sqlc copied to clipboard

Column rename through `CHANGE COLUMN` changes column order

Open Luit opened this issue 3 years ago • 2 comments

Version

1.14.0

What happened?

After I noticed #1605 was added to 1.14 I ran the new version against our code, as I know there's a few CHANGE COLUMN statements in there. I noticed the ones that don't change the name are also impacted by this change, as they're pulled down to the last position in the column list it seems.

I only tested this with our own code against a MariaDB. In my case, column order doesn't change when CHANGE COLUMN is used to change type, change name, or both.

Relevant log output

No response

Database schema

No response

SQL queries

No response

Configuration

No response

Playground URL

No response

What operating system are you using?

Linux

What database engines are you using?

MySQL

What type of code are you generating?

Go

Luit avatar Jun 13 '22 09:06 Luit

@Luit What impact does the ordering of the columns have on your queries?

kyleconroy avatar Aug 29 '22 02:08 kyleconroy

I noticed this caused a diff on my structs even though nothing functionally changed. I'm not entirely sure whether sqlc actually maintains column order similar to how MariaDB(/MySQL) does this, but so far column order and struct order was the same for our cases. If ADD COLUMN x AFTER y doesn't have an impact on struct order either, then I'm not sure this one is important either.

Luit avatar Aug 29 '22 07:08 Luit