Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postgreSQL数据库使用update_casbin_site_grouping方法批量插入数据时,出现表auth_casbin_rule的id不能为空错误。 #24

Open
n0thingcode opened this issue Sep 24, 2023 · 2 comments · May be fixed by #34

Comments

@n0thingcode
Copy link

postgreSQL数据库使用update_casbin_site_grouping方法时,错误如下:
sqlalchemy.exc.IntegrityError: (psycopg2.errors.NotNullViolation) null value in column "id" of relation "auth_casbin_rule" violates not-null constraint。
错误原因:fastapi_user_auth\utils\sqlachemy_adapter.py内第134行
values.append(self.parse_rule(ptype, rule).dict())
#导出dict时,包含id字段,id字段为NONE,postgreSQL数据库不允许id为null的数据插入。
未测试建议:能否在导出dict时排除id字段。修改原同行代码为:
values.append(self.parse_rule(ptype, rule).dict(exclude={"id"}))

@amisadmin
Copy link
Owner

欢迎测试后提交PR,我这边细节顾不过来

Cactiw pushed a commit to Cactiw/fastapi-user-auth that referenced this issue Jan 9, 2024
Cactiw added a commit to Cactiw/fastapi-user-auth that referenced this issue Jan 9, 2024
@huangjunyingnb
Copy link

@amisadmin 可以合并一下吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants