Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (the *CasbinRule) TableName() string {

// CasbinRule .
type CasbinRule struct {
PType string `xorm:"varchar(100) index not null default ''"`
Ptype string `xorm:"varchar(100) index not null default ''"`
V0 string `xorm:"varchar(100) index not null default ''"`
V1 string `xorm:"varchar(100) index not null default ''"`
V2 string `xorm:"varchar(100) index not null default ''"`
Expand All @@ -60,7 +60,7 @@ type Adapter struct {

// Filter .
type Filter struct {
PType []string
Ptype []string
V0 []string
V1 []string
V2 []string
Expand Down Expand Up @@ -249,7 +249,7 @@ func (a *Adapter) dropTable() error {
}

func loadPolicyLine(line *CasbinRule, model model.Model) {
var p = []string{line.PType,
var p = []string{line.Ptype,
line.V0, line.V1, line.V2, line.V3, line.V4, line.V5}
var lineText string
if line.V5 != "" {
Expand Down Expand Up @@ -285,7 +285,7 @@ func (a *Adapter) LoadPolicy(model model.Model) error {
}

func (a *Adapter) genPolicyLine(ptype string, rule []string) *CasbinRule {
line := CasbinRule{PType: ptype, tableName: a.getFullTableName()}
line := CasbinRule{Ptype: ptype, tableName: a.getFullTableName()}

l := len(rule)
if l > 0 {
Expand Down Expand Up @@ -393,7 +393,7 @@ func (a *Adapter) RemovePolicies(sec string, ptype string, rules [][]string) err

// RemoveFilteredPolicy removes policy rules that match the filter from the storage.
func (a *Adapter) RemoveFilteredPolicy(sec string, ptype string, fieldIndex int, fieldValues ...string) error {
line := CasbinRule{PType: ptype, tableName: a.getFullTableName()}
line := CasbinRule{Ptype: ptype, tableName: a.getFullTableName()}

idx := fieldIndex + len(fieldValues)
if fieldIndex <= 0 && idx > 0 {
Expand Down Expand Up @@ -448,7 +448,7 @@ func (a *Adapter) filterQuery(session *xorm.Session, filter Filter) *xorm.Sessio
col string
val []string
}{
{"p_type", filter.PType},
{"ptype", filter.Ptype},
{"v0", filter.V0},
{"v1", filter.V1},
{"v2", filter.V2},
Expand Down Expand Up @@ -501,7 +501,7 @@ func (a *Adapter) UpdateFilteredPolicies(sec string, ptype string, newPolicies [
// UpdateFilteredPolicies deletes old rules and adds new rules.
line := &CasbinRule{}

line.PType = ptype
line.Ptype = ptype
if fieldIndex <= 0 && 0 < fieldIndex+len(fieldValues) {
line.V0 = fieldValues[0-fieldIndex]
}
Expand Down Expand Up @@ -557,8 +557,8 @@ func (a *Adapter) UpdateFilteredPolicies(sec string, ptype string, newPolicies [

func (c *CasbinRule) toStringPolicy() []string {
policy := make([]string, 0)
if c.PType != "" {
policy = append(policy, c.PType)
if c.Ptype != "" {
policy = append(policy, c.Ptype)
}
if c.V0 != "" {
policy = append(policy, c.V0)
Expand All @@ -582,9 +582,9 @@ func (c *CasbinRule) toStringPolicy() []string {
}

func (c *CasbinRule) queryString() (interface{}, []interface{}) {
queryArgs := []interface{}{c.PType}
queryArgs := []interface{}{c.Ptype}

queryStr := "p_type = ?"
queryStr := "ptype = ?"
if c.V0 != "" {
queryStr += " and v0 = ?"
queryArgs = append(queryArgs, c.V0)
Expand Down