Skip to content

Commit 1b1374b

Browse files
authored
fest: Add compiler support for NOTIFY and LISTEN (PostgreSQL) (#2363)
1 parent 77aadba commit 1b1374b

File tree

7 files changed

+102
-1
lines changed

7 files changed

+102
-1
lines changed

internal/compiler/output_columns.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ func (c *Compiler) outputColumns(qc *QueryCatalog, node ast.Node) ([]*Column, er
115115
}
116116
case *ast.CallStmt:
117117
targets = &ast.List{}
118-
case *ast.TruncateStmt, *ast.RefreshMatViewStmt:
118+
case *ast.TruncateStmt, *ast.RefreshMatViewStmt, *ast.NotifyStmt, *ast.ListenStmt:
119119
targets = &ast.List{}
120120
case *ast.UpdateStmt:
121121
targets = n.ReturningList
@@ -491,6 +491,8 @@ func (c *Compiler) sourceTables(qc *QueryCatalog, node ast.Node) ([]*Table, erro
491491
}
492492
case *ast.CallStmt:
493493
list = &ast.List{}
494+
case *ast.NotifyStmt, *ast.ListenStmt:
495+
list = &ast.List{}
494496
default:
495497
return nil, fmt.Errorf("sourceTables: unsupported node type: %T", n)
496498
}

internal/compiler/parse.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ func (c *Compiler) parseQuery(stmt ast.Node, src string, o opts.Parser) (*Query,
4848
if err != nil {
4949
return nil, err
5050
}
51+
case *ast.ListenStmt:
52+
case *ast.NotifyStmt:
5153
case *ast.TruncateStmt:
5254
case *ast.UpdateStmt:
5355
case *ast.RefreshMatViewStmt:

internal/endtoend/testdata/notifylisten/postgresql/pgx/v5/go/db.go

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/notifylisten/postgresql/pgx/v5/go/models.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/endtoend/testdata/notifylisten/postgresql/pgx/v5/go/query.sql.go

Lines changed: 37 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- name: NotifyTest :exec
2+
NOTIFY test;
3+
4+
-- name: NotifyWithMessage :exec
5+
NOTIFY test, 'msg';
6+
7+
-- name: ListenTest :exec
8+
LISTEN test;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"version": "1",
3+
"packages": [
4+
{
5+
"path": "go",
6+
"engine": "postgresql",
7+
"sql_package": "pgx/v5",
8+
"name": "querytest",
9+
"schema": "query.sql",
10+
"queries": "query.sql",
11+
}
12+
]
13+
}

0 commit comments

Comments
 (0)