closes 5254: %COL% should be a common placeholder
This commit is contained in:
parent
bc7f6ffa1a
commit
3673a322a6
@ -1,8 +1,9 @@
|
|||||||
# developing
|
# developing
|
||||||
- [httplib: fix unstable unit test which use the httplib.org](https://github.com/beego/beego/pull/5232)
|
- [httplib: fix unstable unit test which use the httplib.org](https://github.com/beego/beego/pull/5232)
|
||||||
- [remove adapter package](https://github.com/beego/beego/pull/5239)
|
- [rft: remove adapter package](https://github.com/beego/beego/pull/5239)
|
||||||
- [feat: add write-delete cache mode](https://github.com/beego/beego/pull/5242)
|
- [feat: add write-delete cache mode](https://github.com/beego/beego/pull/5242)
|
||||||
- [fix 5255: Check the rows.Err() if rows.Next() is false](https://github.com/beego/beego/pull/5256)
|
- [fix 5255: Check the rows.Err() if rows.Next() is false](https://github.com/beego/beego/pull/5256)
|
||||||
|
- [orm: missing handling %COL% placeholder](https://github.com/beego/beego/pull/5257)
|
||||||
|
|
||||||
## ORM refactoring
|
## ORM refactoring
|
||||||
- [introducing internal/models pkg](https://github.com/beego/beego/pull/5238)
|
- [introducing internal/models pkg](https://github.com/beego/beego/pull/5238)
|
||||||
|
|||||||
@ -33,6 +33,11 @@ func getColumnTyp(al *alias, fi *models.FieldInfo) (col string) {
|
|||||||
fieldType := fi.FieldType
|
fieldType := fi.FieldType
|
||||||
fieldSize := fi.Size
|
fieldSize := fi.Size
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
// handling the placeholder, including %COL%
|
||||||
|
col = strings.ReplaceAll(col, "%COL%", fi.Column)
|
||||||
|
}()
|
||||||
|
|
||||||
checkColumn:
|
checkColumn:
|
||||||
switch fieldType {
|
switch fieldType {
|
||||||
case TypeBooleanField:
|
case TypeBooleanField:
|
||||||
|
|||||||
37
client/orm/cmd_utils_test.go
Normal file
37
client/orm/cmd_utils_test.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package orm
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/beego/beego/v2/client/orm/internal/models"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Test_getColumnTyp(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
name string
|
||||||
|
fi *models.FieldInfo
|
||||||
|
al *alias
|
||||||
|
|
||||||
|
wantCol string
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
// https://github.com/beego/beego/issues/5254
|
||||||
|
name: "issue 5254",
|
||||||
|
fi: &models.FieldInfo{
|
||||||
|
FieldType: TypePositiveIntegerField,
|
||||||
|
Column: "my_col",
|
||||||
|
},
|
||||||
|
al: &alias{
|
||||||
|
DbBaser: newdbBasePostgres(),
|
||||||
|
},
|
||||||
|
wantCol: `bigint CHECK("my_col" >= 0)`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tc := range testCases {
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
col := getColumnTyp(tc.al, tc.fi)
|
||||||
|
assert.Equal(t, tc.wantCol, col)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -39,12 +39,12 @@ func serverStaticRouter(ctx *context.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
forbidden, filePath, fileInfo, err := lookupFile(ctx)
|
fbd, filePath, fileInfo, err := lookupFile(ctx)
|
||||||
if err == errNotStaticRequest {
|
if err == errNotStaticRequest {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if forbidden {
|
if fbd {
|
||||||
exception("403", ctx)
|
exception("403", ctx)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user