File tree Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Expand file tree Collapse file tree 2 files changed +37
-1
lines changed Original file line number Diff line number Diff line change @@ -353,8 +353,12 @@ func Update(c *pg.Catalog, stmt nodes.Node) error {
353
353
args := make ([]pg.Argument , arity )
354
354
for i , item := range n .Parameters .Items {
355
355
arg := item .(nodes.FunctionParameter )
356
+ var name string
357
+ if arg .Name != nil {
358
+ name = * arg .Name
359
+ }
356
360
args [i ] = pg.Argument {
357
- Name : * arg . Name ,
361
+ Name : name ,
358
362
DataType : join (arg .ArgType .Names , "." ),
359
363
HasDefault : arg .Defexpr != nil ,
360
364
}
Original file line number Diff line number Diff line change @@ -322,6 +322,13 @@ func TestUpdate(t *testing.T) {
322
322
` ,
323
323
pg .NewCatalog (),
324
324
},
325
+ {
326
+ `
327
+ DROP FUNCTION IF EXISTS bar(text);
328
+ DROP FUNCTION IF EXISTS bar(text) CASCADE;
329
+ ` ,
330
+ pg .NewCatalog (),
331
+ },
325
332
{
326
333
`
327
334
CREATE TABLE venues (id SERIAL PRIMARY KEY);
@@ -343,6 +350,31 @@ func TestUpdate(t *testing.T) {
343
350
},
344
351
},
345
352
},
353
+ { // first argument has no name
354
+ `
355
+ CREATE FUNCTION foo(TEXT) RETURNS bool AS $$ SELECT true $$ LANGUAGE sql;
356
+ ` ,
357
+ pg.Catalog {
358
+ Schemas : map [string ]pg.Schema {
359
+ "public" : {
360
+ Funcs : map [string ][]pg.Function {
361
+ "foo" : []pg.Function {
362
+ {
363
+ Name : "foo" ,
364
+ Arguments : []pg.Argument {
365
+ {
366
+ Name : "" ,
367
+ DataType : "text" ,
368
+ },
369
+ },
370
+ ReturnType : "bool" ,
371
+ },
372
+ },
373
+ },
374
+ },
375
+ },
376
+ },
377
+ },
346
378
{ // same name, different arity
347
379
`
348
380
CREATE FUNCTION foo(bar TEXT) RETURNS bool AS $$ SELECT true $$ LANGUAGE sql;
You can’t perform that action at this time.
0 commit comments