doc bug fixed

This commit is contained in:
Lunny Xiao 2014-05-08 20:11:43 +08:00
parent 65d72ed8ca
commit 3426738746
2 changed files with 4 additions and 2 deletions

View File

@ -139,7 +139,9 @@ Of course, you can implement IMapper to make custom naming strategy.
It's idealized of using IMapper for all naming. But if table or column is not in rule, we need new method to archive.
`engine.Table()` can change the database table name for struct. The struct tag `xorm:"'table_name'"` can set column name for struct field. Use a pair of single quotes to prevent confusion for column's definition in struct tag. If not in confusion, ignore single quotes.
* If struct or pointer of struct has `TableName() string` method, the return value will be the struct's table name.
* `engine.Table()` can change the database table name for struct. The struct tag `xorm:"'table_name'"` can set column name for struct field. Use a pair of single quotes to prevent confusion for column's definition in struct tag. If not in confusion, ignore single quotes.
<a name="23" id="23"></a>
### 2.4.Column definition

View File

@ -141,7 +141,7 @@ engine.SetColumnMapper(SnakeMapper{})
如果所有的命名都是按照IMapper的映射来操作的那当然是最理想的。但是如果碰到某个表名或者某个字段名跟映射规则不匹配时我们就需要别的机制来改变。
* 如果struct拥有`Tablename() string`的成员方法那么此方法的返回值即是该struct默认对应的数据库表名。
* 如果struct拥有`TableName() string`的成员方法那么此方法的返回值即是该struct默认对应的数据库表名。
* 通过`engine.Table()`方法可以改变struct对应的数据库表的名称通过sturct中field对应的Tag中使用`xorm:"'column_name'"`可以使该field对应的Column名称为指定名称。这里使用两个单引号将Column名称括起来是为了防止名称冲突因为我们在Tag中还可以对这个Column进行更多的定义。如果名称不冲突的情况单引号也可以不使用。