File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -353,8 +353,12 @@ func Update(c *pg.Catalog, stmt nodes.Node) error {
353353 args := make ([]pg.Argument , arity )
354354 for i , item := range n .Parameters .Items {
355355 arg := item .(nodes.FunctionParameter )
356+ var name string
357+ if arg .Name != nil {
358+ name = * arg .Name
359+ }
356360 args [i ] = pg.Argument {
357- Name : * arg . Name ,
361+ Name : name ,
358362 DataType : join (arg .ArgType .Names , "." ),
359363 HasDefault : arg .Defexpr != nil ,
360364 }
Original file line number Diff line number Diff line change @@ -322,6 +322,13 @@ func TestUpdate(t *testing.T) {
322322 ` ,
323323 pg .NewCatalog (),
324324 },
325+ {
326+ `
327+ DROP FUNCTION IF EXISTS bar(text);
328+ DROP FUNCTION IF EXISTS bar(text) CASCADE;
329+ ` ,
330+ pg .NewCatalog (),
331+ },
325332 {
326333 `
327334 CREATE TABLE venues (id SERIAL PRIMARY KEY);
@@ -343,6 +350,31 @@ func TestUpdate(t *testing.T) {
343350 },
344351 },
345352 },
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+ },
346378 { // same name, different arity
347379 `
348380 CREATE FUNCTION foo(bar TEXT) RETURNS bool AS $$ SELECT true $$ LANGUAGE sql;
You can’t perform that action at this time.
0 commit comments