Skip to content
This repository was archived by the owner on Sep 2, 2024. It is now read-only.

Commit 91dd037

Browse files
committed
fixed a bug when being root in postgres read/write
1 parent e2541c4 commit 91dd037

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

database/postgresql/query.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ func applyFilter(where string, filters map[string]interface{}) string {
5353
}
5454

5555
func secureRead(auth internal.Auth, col string) string {
56-
if strings.HasPrefix(col, "pub_") && auth.Role < 100 {
57-
return "WHERE 1=1 "
56+
if strings.HasPrefix(col, "pub_") || auth.Role == 100 {
57+
return "WHERE $1=$1 AND $2=$2 "
5858
}
5959

6060
switch internal.ReadPermission(col) {
@@ -69,8 +69,8 @@ func secureRead(auth internal.Auth, col string) string {
6969
}
7070

7171
func secureWrite(auth internal.Auth, col string) string {
72-
if strings.HasPrefix(col, "pub_") && auth.Role < 100 {
73-
return "WHERE 1=1 "
72+
if strings.HasPrefix(col, "pub_") || auth.Role == 100 {
73+
return "WHERE $1=$1 AND $2=$2 "
7474
}
7575

7676
switch internal.WritePermission(col) {

0 commit comments

Comments
 (0)