Skip to content
This repository has been archived by the owner on Sep 7, 2021. It is now read-only.
This repository is currently being migrated. It's locked while the migration is in progress.

Add another method of setting table name. #89

Closed
ahall opened this issue Apr 8, 2014 · 0 comments
Closed

Add another method of setting table name. #89

ahall opened this issue Apr 8, 2014 · 0 comments
Assignees

Comments

@ahall
Copy link
Contributor

ahall commented Apr 8, 2014

At the moment if your table name is not the same as the class name you got to set it for every single operation e.g.: session.Table("users").Find(&users). Would be nice if you could set it on the struct such as:

type User struct {
Id int64 xorm:"id"
UserName string xorm:"username"
FullName string xorm:"full_name"
}

func (this User) TableName() {
return "users"
}

I like the idea of declaring the table once and then using the fields instead of stating table and column names and use Go's type system. It makes it easier to rename columns in the future and make the compiler help you catch references to it.

@lunny lunny self-assigned this Apr 8, 2014
@lunny lunny closed this as completed in 9b23e7d Apr 8, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants