Comments (10)
@liupzmin you need to check whether model
is null before calling this function.
from xorm-adapter.
@liupzmin you need to check whether
model
is null before calling this function.
@hsluoyz Please, correct me if I'm wrong. Consider this scenario, my goal is to remove all policies, which is not possible in the current situation.
from xorm-adapter.
@liupzmin you should call ClearPolicy()
first, then SavePolicy()
from xorm-adapter.
@liupzmin you should call
ClearPolicy()
first, thenSavePolicy()
I don't understand what you mean. the ClearPolicy()
just set policy
to nil, SavePolicy()
will collect the lines
of policies, and then insert it to db, the slice of lines
that collected by SavePolicy()
is empty now, this is why a.engine.Insert(&lines)
reports error .
from xorm-adapter.
@closetool
from xorm-adapter.
@liupzmin did you try what I said? Does it work?
from xorm-adapter.
@liupzmin did you try what I said? Does it work?
yes, I have tried, Please see the attachment screenshot:
from xorm-adapter.
Although the final logical result is correct, I mean, I don't want to get an error.
from xorm-adapter.
may be we can do this:
for ptype, ast := range model["p"] {
for _, rule := range ast.Policy {
line := a.genPolicyLine(ptype, rule)
lines = append(lines, line)
}
}
for ptype, ast := range model["g"] {
for _, rule := range ast.Policy {
line := a.genPolicyLine(ptype, rule)
lines = append(lines, line)
}
}
// check here to avoid inserting empty slice
if len(lines) <= 0 {
return nil
}
_, err = a.engine.Insert(&lines)
return err
from xorm-adapter.
from xorm-adapter.
Related Issues (20)
- Is it necessary to add 'p_type' tag to compatible the old version? HOT 1
- the func SavePolicy will drop table? HOT 2
- xorm is moving to gitea.com HOT 1
- panic: interface conversion: *xormadapter.Adapter is not persist.Adapter: missing method LoadPolicy HOT 9
- fail to mssql HOT 2
- Adapter.SavePolicy() not safe for concurrent use? HOT 6
- Implement UpdatePolicy() API (aka UpdatableAdapter interface) HOT 1
- Interface conversion (Panic) *xormadapter.Adapter is not persist.UpdatableAdapter: missing method UpdatePolicies HOT 2
- Switch to GitHub Actions CI and add semantic-release HOT 2
- Missing method UpdateFilteredPolicies HOT 4
- Support table prefix HOT 2
- UpdateFilteredPolicies returns the oldPolicy containing ptype, Is this a bug? HOT 6
- README is wrong (for v1 only) HOT 1
- [BREAKING CHANGE] Rename PType to Ptype like gorm-adapter HOT 2
- [Question] Can I configure casbin xorm to "skip" table creation ? HOT 7
- Fails to connect to pg 16.1 HOT 5
- xorm-adapter v2 not find HOT 2
- feature: fix the context adapter feature HOT 1
- occur err when using dameng HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from xorm-adapter.