|
@@ -16,9 +16,9 @@ import (
|
|
|
type Class struct {
|
|
type Class struct {
|
|
|
ID string `sqlmapping:"key;"`
|
|
ID string `sqlmapping:"key;"`
|
|
|
Name string `sqlmapping:"update:canClear;notQuery;"`
|
|
Name string `sqlmapping:"update:canClear;notQuery;"`
|
|
|
- StudentNum int `sqlmapping:"column:student_num;notUpdate;queryConditionCallback;" tablerow:"column:student_num"`
|
|
|
|
|
- CreatedTime *time.Time `tablerow:"callback"`
|
|
|
|
|
- Ignored string `sqlmapping:"-" tablerow:"-"`
|
|
|
|
|
|
|
+ StudentNum int `sqlmapping:"column:student_num;notUpdate;queryConditionCallback;result_column:studentNum"`
|
|
|
|
|
+ CreatedTime *time.Time `sqlmapping:"resultCallback"`
|
|
|
|
|
+ Ignored string `sqlmapping:"-"`
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const (
|
|
const (
|
|
@@ -209,7 +209,8 @@ func TestRawSqlTemplate(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
queryExecuteParams, err := raw_sql_tpl.QueryExecuteParams{
|
|
queryExecuteParams, err := raw_sql_tpl.QueryExecuteParams{
|
|
|
- TableName: tableName,
|
|
|
|
|
|
|
+ TableName: tableName,
|
|
|
|
|
+ SelectColumns: []string{"id", "name", "student_num as student_num_alias", "created_time"},
|
|
|
Conditions: []raw_sql_tpl.Condition{
|
|
Conditions: []raw_sql_tpl.Condition{
|
|
|
{
|
|
{
|
|
|
Column: "id",
|
|
Column: "id",
|
|
@@ -232,7 +233,8 @@ func TestRawSqlTemplate(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
newQueryExecuteParams, err := raw_sql_tpl.QueryExecuteParams{
|
|
newQueryExecuteParams, err := raw_sql_tpl.QueryExecuteParams{
|
|
|
- TableName: tableName,
|
|
|
|
|
|
|
+ TableName: tableName,
|
|
|
|
|
+ SelectColumns: []string{"id", "name", "student_num as student_num_alias", "created_time"},
|
|
|
Conditions: []raw_sql_tpl.Condition{
|
|
Conditions: []raw_sql_tpl.Condition{
|
|
|
{
|
|
{
|
|
|
Column: "id",
|
|
Column: "id",
|
|
@@ -329,7 +331,7 @@ func TestRawSqlTemplate(t *testing.T) {
|
|
|
|
|
|
|
|
if queryResults[0]["id"].(string) != classID ||
|
|
if queryResults[0]["id"].(string) != classID ||
|
|
|
queryResults[0]["name"].(string) != className ||
|
|
queryResults[0]["name"].(string) != className ||
|
|
|
- queryResults[0]["student_num"].(float64) != float64(studentNum) ||
|
|
|
|
|
|
|
+ queryResults[0]["student_num_alias"].(float64) != float64(studentNum) ||
|
|
|
queryResults[0]["created_time"].(string) != execeptedCreatedTime {
|
|
queryResults[0]["created_time"].(string) != execeptedCreatedTime {
|
|
|
t.Fatal("查询数据不正确")
|
|
t.Fatal("查询数据不正确")
|
|
|
}
|
|
}
|
|
@@ -355,7 +357,7 @@ func TestRawSqlTemplate(t *testing.T) {
|
|
|
|
|
|
|
|
if queryResults[0]["id"].(string) != classID ||
|
|
if queryResults[0]["id"].(string) != classID ||
|
|
|
queryResults[0]["name"].(string) != newClassName ||
|
|
queryResults[0]["name"].(string) != newClassName ||
|
|
|
- queryResults[0]["student_num"].(float64) != float64(newStudentNum) ||
|
|
|
|
|
|
|
+ queryResults[0]["student_num_alias"].(float64) != float64(newStudentNum) ||
|
|
|
queryResults[0]["created_time"].(string) != execeptedCreatedTime {
|
|
queryResults[0]["created_time"].(string) != execeptedCreatedTime {
|
|
|
t.Fatal("查询数据不正确")
|
|
t.Fatal("查询数据不正确")
|
|
|
}
|
|
}
|