bug fixed
This commit is contained in:
parent
dd9c707f50
commit
78fb484ce0
16
base_test.go
16
base_test.go
|
@ -3175,7 +3175,9 @@ func testPointerData(engine *Engine, t *testing.T) {
|
||||||
// using instance type should just work too
|
// using instance type should just work too
|
||||||
nullData2Get := NullData2{}
|
nullData2Get := NullData2{}
|
||||||
|
|
||||||
has, err = engine.Table("null_data").Id(nullData.Id).Get(&nullData2Get)
|
tableName := engine.tableMapper.Obj2Table("NullData")
|
||||||
|
|
||||||
|
has, err = engine.Table(tableName).Id(nullData.Id).Get(&nullData2Get)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -3540,7 +3542,9 @@ func testNullValue(engine *Engine, t *testing.T) {
|
||||||
// update to null values
|
// update to null values
|
||||||
nullDataUpdate = NullData{}
|
nullDataUpdate = NullData{}
|
||||||
|
|
||||||
cnt, err = engine.Id(nullData.Id).Cols("string_ptr").Update(&nullDataUpdate)
|
string_ptr := engine.columnMapper.Obj2Table("StringPtr")
|
||||||
|
|
||||||
|
cnt, err = engine.Id(nullData.Id).Cols(string_ptr).Update(&nullDataUpdate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Error(err)
|
t.Error(err)
|
||||||
panic(err)
|
panic(err)
|
||||||
|
@ -3896,3 +3900,11 @@ func testAll3(engine *Engine, t *testing.T) {
|
||||||
fmt.Println("-------------- testStringPK --------------")
|
fmt.Println("-------------- testStringPK --------------")
|
||||||
testStringPK(engine, t)
|
testStringPK(engine, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testAllSnakeMapper(engine *Engine, t *testing.T) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func testAllSameMapper(engine *Engine, t *testing.T) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -35,6 +35,30 @@ func TestMysql(t *testing.T) {
|
||||||
testAll3(engine, t)
|
testAll3(engine, t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestMysqlSameMapper(t *testing.T) {
|
||||||
|
err := mysqlDdlImport()
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
engine, err := NewEngine("mysql", "root:@/xorm_test3?charset=utf8")
|
||||||
|
defer engine.Close()
|
||||||
|
if err != nil {
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
engine.ShowSQL = showTestSql
|
||||||
|
engine.ShowErr = showTestSql
|
||||||
|
engine.ShowWarn = showTestSql
|
||||||
|
engine.ShowDebug = showTestSql
|
||||||
|
engine.SetMapper(SameMapper{})
|
||||||
|
|
||||||
|
testAll(engine, t)
|
||||||
|
testAll2(engine, t)
|
||||||
|
testAll3(engine, t)
|
||||||
|
}
|
||||||
|
|
||||||
func TestMysqlWithCache(t *testing.T) {
|
func TestMysqlWithCache(t *testing.T) {
|
||||||
err := mysqlDdlImport()
|
err := mysqlDdlImport()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -510,7 +510,7 @@ func (statement *Statement) Distinct(columns ...string) *Statement {
|
||||||
func (statement *Statement) Cols(columns ...string) *Statement {
|
func (statement *Statement) Cols(columns ...string) *Statement {
|
||||||
newColumns := col2NewCols(columns...)
|
newColumns := col2NewCols(columns...)
|
||||||
for _, nc := range newColumns {
|
for _, nc := range newColumns {
|
||||||
statement.columnMap[nc] = true
|
statement.columnMap[strings.ToLower(nc)] = true
|
||||||
}
|
}
|
||||||
statement.ColumnStr = statement.Engine.Quote(strings.Join(newColumns, statement.Engine.Quote(", ")))
|
statement.ColumnStr = statement.Engine.Quote(strings.Join(newColumns, statement.Engine.Quote(", ")))
|
||||||
return statement
|
return statement
|
||||||
|
@ -521,7 +521,7 @@ func (statement *Statement) UseBool(columns ...string) *Statement {
|
||||||
if len(columns) > 0 {
|
if len(columns) > 0 {
|
||||||
newColumns := col2NewCols(columns...)
|
newColumns := col2NewCols(columns...)
|
||||||
for _, nc := range newColumns {
|
for _, nc := range newColumns {
|
||||||
statement.boolColumnMap[nc] = true
|
statement.boolColumnMap[strings.ToLower(nc)] = true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
statement.allUseBool = true
|
statement.allUseBool = true
|
||||||
|
@ -533,7 +533,7 @@ func (statement *Statement) UseBool(columns ...string) *Statement {
|
||||||
func (statement *Statement) Omit(columns ...string) {
|
func (statement *Statement) Omit(columns ...string) {
|
||||||
newColumns := col2NewCols(columns...)
|
newColumns := col2NewCols(columns...)
|
||||||
for _, nc := range newColumns {
|
for _, nc := range newColumns {
|
||||||
statement.columnMap[nc] = false
|
statement.columnMap[strings.ToLower(nc)] = false
|
||||||
}
|
}
|
||||||
statement.OmitStr = statement.Engine.Quote(strings.Join(newColumns, statement.Engine.Quote(", ")))
|
statement.OmitStr = statement.Engine.Quote(strings.Join(newColumns, statement.Engine.Quote(", ")))
|
||||||
}
|
}
|
||||||
|
@ -586,7 +586,7 @@ func (statement *Statement) genColumnStr() string {
|
||||||
colNames := make([]string, 0)
|
colNames := make([]string, 0)
|
||||||
for _, col := range table.Columns {
|
for _, col := range table.Columns {
|
||||||
if statement.OmitStr != "" {
|
if statement.OmitStr != "" {
|
||||||
if _, ok := statement.columnMap[col.Name]; ok {
|
if _, ok := statement.columnMap[strings.ToLower(col.Name)]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
7
table.go
7
table.go
|
@ -411,8 +411,9 @@ func (table *Table) genCols(session *Session, bean interface{}, useCol bool, inc
|
||||||
args := make([]interface{}, 0)
|
args := make([]interface{}, 0)
|
||||||
|
|
||||||
for _, col := range table.Columns {
|
for _, col := range table.Columns {
|
||||||
|
lColName := strings.ToLower(col.Name)
|
||||||
if useCol && !col.IsVersion && !col.IsCreated && !col.IsUpdated {
|
if useCol && !col.IsVersion && !col.IsCreated && !col.IsUpdated {
|
||||||
if _, ok := session.Statement.columnMap[col.Name]; !ok {
|
if _, ok := session.Statement.columnMap[lColName]; !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -439,12 +440,12 @@ func (table *Table) genCols(session *Session, bean interface{}, useCol bool, inc
|
||||||
}
|
}
|
||||||
|
|
||||||
if session.Statement.ColumnStr != "" {
|
if session.Statement.ColumnStr != "" {
|
||||||
if _, ok := session.Statement.columnMap[col.Name]; !ok {
|
if _, ok := session.Statement.columnMap[lColName]; !ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if session.Statement.OmitStr != "" {
|
if session.Statement.OmitStr != "" {
|
||||||
if _, ok := session.Statement.columnMap[col.Name]; ok {
|
if _, ok := session.Statement.columnMap[lColName]; ok {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue