hsluoyz commented on issue #106: URL: https://github.com/apache/casbin-sqlx-adapter/issues/106#issuecomment-4289768545
@Ddystopia Thanks for raising this! This behavior is actually intentional. In Casbin's design, `sec` is always the first character of `ptype` — for example, `ptype = "p2"` implies `sec = "p"`, and `ptype = "g2"` implies `sec = "g"`. The two values are never independent. For the **write methods** (`add_policy`, `remove_policy`, etc.), the adapter stores and queries records by `ptype` directly in the database, so `sec` is redundant — we don't need it. The `_sec` prefix is Rust's convention for intentionally unused parameters. For the **read path** (`load_policy`, `load_filtered_policy`), we do need to walk the model hierarchy `sec → ptype → rules`, so we derive `sec` from `ptype` via `ptype.chars().next()`. This is equivalent to using the `sec` parameter the framework would pass — the result is always identical. That said, if you've found a concrete case where `sec != ptype.chars().next()` causes incorrect behavior, please share a reproducer and we'll take another look. Otherwise we'll close this as by design. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
