Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for 'default' parameter #119

Open
KES777 opened this issue Jun 24, 2019 · 2 comments
Open

Add support for 'default' parameter #119

KES777 opened this issue Jun 24, 2019 · 2 comments

Comments

@KES777
Copy link
Contributor

KES777 commented Jun 24, 2019

code example:

	$sqlt->add_procedure(
		name =>  'order_total_suma',
		parameters =>  [
			{ argmode => 'in',  name => '_deep',          type => 'tstzrange', default => 1 },
		],
...

expected SQL:

CREATE FUNCTION "order_total_suma" (in _deep tstzrange default 1)  ...
@KES777
Copy link
Contributor Author

KES777 commented Jun 24, 2019

--- a/lib/SQL/Translator/Producer/PostgreSQL.pm
+++ b/lib/SQL/Translator/Producer/PostgreSQL.pm
@@ -756,9 +756,13 @@ sub create_procedure {
   my @args = ();
   foreach my $arg (@{$procedure->parameters}) {
     $arg = {name => $arg} if ref($arg) ne 'HASH';
-    push @args, join(' ', map $arg->{$_},
+    my $param =  join(' ', map $arg->{$_},
                           grep defined($arg->{$_}),
                           qw/argmode name type/);
+    if( defined $arg->{ default } ) {
+        $param .= ' default ' .$arg->{ default };
+    }
+    push @args, $param;
   }
   $sql .= join(', ', @args);
   $sql .= ')';

@KES777
Copy link
Contributor Author

KES777 commented Apr 6, 2023

@rabbiveesh Hello. I saw recent updates. Is there a chance to apply this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant