1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 21:29:42 +02:00

Improve SQL store for new schema

This commit is contained in:
sauls8t 2018-09-20 17:07:40 +01:00
parent 8ee63de6c7
commit fe7389e7ca
3 changed files with 4 additions and 4 deletions

View file

@ -246,7 +246,7 @@ func (s Scope) GetDocumentPermissions(ctx domain.RequestContext, documentID stri
FROM dmz_permission
WHERE c_orgid=? AND c_location='document' AND c_refid=? AND c_who='user'
UNION ALL
SELECT id, p.c_orgid AS orgid, p.c_who AS who, p.c_whoid AS whoid, p.c_action AS action, p.c_scope AS scope, p.c_location AS location, p.c_refid AS refid
SELECT p.id, p.c_orgid AS orgid, p.c_who AS who, p.c_whoid AS whoid, p.c_action AS action, p.c_scope AS scope, p.c_location AS location, p.c_refid AS refid
FROM dmz_permission p
LEFT JOIN dmz_group_member r ON p.c_whoid=r.c_groupid
WHERE p.c_orgid=? AND p.c_location='document' AND p.c_refid=? AND p.c_who='role'`,
@ -267,7 +267,7 @@ func (s Scope) GetDocumentPermissions(ctx domain.RequestContext, documentID stri
func (s Scope) DeleteDocumentPermissions(ctx domain.RequestContext, documentID string) (rows int64, err error) {
b := mysql.BaseQuery{}
sql := fmt.Sprintf("DELETE FROM dmz_permission WHERE c_orgid='%s' AND location='document' AND c_refid='%s'", ctx.OrgID, documentID)
sql := fmt.Sprintf("DELETE FROM dmz_permission WHERE c_orgid='%s' AND c_location='document' AND c_refid='%s'", ctx.OrgID, documentID)
return b.DeleteWhere(ctx.Transaction, sql)
}

View file

@ -309,7 +309,7 @@ func (s Scope) ForgotUserPassword(ctx domain.RequestContext, email, token string
// CountActiveUsers returns the number of active users in the system.
func (s Scope) CountActiveUsers() (c int) {
row := s.Runtime.Db.QueryRow("SELECT count(*) FROM dmz_user WHERE c_refid IN (SELECT c_userid FROM dmz_user_account WHERE active=1)")
row := s.Runtime.Db.QueryRow("SELECT count(*) FROM dmz_user WHERE c_refid IN (SELECT c_userid FROM dmz_user_account WHERE c_active=1)")
err := row.Scan(&c)
if err == sql.ErrNoRows {

View file

@ -55,7 +55,7 @@ func InitRuntime(r *env.Runtime, s *domain.Store) bool {
storage.SetMySQLProvider(r, s)
case "percona":
storage.SetMySQLProvider(r, s)
case "pggg":
case "postgres":
// storage.SetPostgresSQLProvider(r, s)
case "mssql":
// storage.SetSQLServerProvider(r, s)