Skip to content

Commit

Permalink
Add ::text[] support
Browse files Browse the repository at this point in the history
  • Loading branch information
arjunlol committed Dec 9, 2024
1 parent 2a012f3 commit 8c42c30
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scripts/install.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

VERSION="0.19.3"
VERSION="0.19.4"

# Detect OS and architecture
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
Expand Down
2 changes: 1 addition & 1 deletion src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"time"
)

const VERSION = "0.19.3"
const VERSION = "0.19.4"

func main() {
config := LoadConfig()
Expand Down
4 changes: 4 additions & 0 deletions src/query_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,10 @@ func TestHandleQuery(t *testing.T) {
"description": {"objoid"},
"values": {},
},
"SELECT word FROM (VALUES ('abort', 'U', 't', 'unreserved', 'can be bare label')) t(word, catcode, barelabel, catdesc, baredesc) WHERE word <> ALL('{a,abs,absolute,action}'::text[])": {
"description": {"word"},
"values": {"abort"},
},
// SHOW
"SHOW search_path": {
"description": {"search_path"},
Expand Down
23 changes: 23 additions & 0 deletions src/select_remapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,29 @@ func (selectRemapper *SelectRemapper) remapTypecast(node *pgQuery.Node) *pgQuery
if typeName == "regclass" {
return typeCast.Arg
}

if typeName == "text" {
arrayStr := typeCast.Arg.GetAConst().GetSval().Sval
arrayStr = strings.Trim(arrayStr, "{}")
elements := strings.Split(arrayStr, ",")

funcCall := &pgQuery.FuncCall{
Funcname: []*pgQuery.Node{
pgQuery.MakeStrNode("list_value"),
},
}

for _, elem := range elements {
funcCall.Args = append(funcCall.Args,
pgQuery.MakeAConstStrNode(elem, 0))
}

return &pgQuery.Node{
Node: &pgQuery.Node_FuncCall{
FuncCall: funcCall,
},
}
}
}
}
return node
Expand Down

0 comments on commit 8c42c30

Please sign in to comment.