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

CreateAllTables generates incorrect SQL when using uint32 as primary key #44

Closed
rickb777 opened this issue May 23, 2013 · 2 comments
Closed
Labels

Comments

@rickb777
Copy link

If a struct has an unsigned ID, then CreateAllTables generates incorrect SQL. E.g.

type Person struct {
    Id               uint32
    Name             string
    Created          int64
    Updated          int64
}

The trace statement says

gorptest: 20:28:16.303405 create table if not exists `person` (`Id` varchar(255) not null primary key auto_increment, `Name` varchar(255), `Created` bigint, `Updated` bigint)  engine=InnoDB charset=UTF8; [[]]

So a varchar(255) has been incorrectly substituted instead of the 'int(10) unsigned' that would be expected.

The same problem applies with uint and uint64 too.

It also seems to happen with all uint, uint32 or uint64 fields, regardless of whether they are primary keys.

@rickb777
Copy link
Author

The problem seems to be caused by MySQLDialect.ToSqlType not including a more complete set of reflect.Kind cases.

@coopernurse
Copy link
Contributor

This is fixed now and tested across the 3 supported databases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants