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

Reserved word is not quoted #132

Open
KES777 opened this issue Mar 5, 2020 · 0 comments
Open

Reserved word is not quoted #132

KES777 opened this issue Mar 5, 2020 · 0 comments

Comments

@KES777
Copy link

KES777 commented Mar 5, 2020

How to reproduce:

	$sqlt->add_procedure(
		name =>  'accounting_ready',
		parameters =>  [
			{ argmode => 'in',  name => '_o',  type => 'order' },
		],
		extra =>  {
			returns =>  { type => 'table( invoice boolean, usage boolean )' },
			definitions =>  [
				{ language  =>  'sql'  },
				{ quote => "\$\$\n",  body => <<'	FUNC' =~ s!^\t!!grm  =~ s!;\n!;/**/\n!grs  }
		SELECT true, true
		FROM "order" o
		WHERE o.id = _o.id
	FUNC
	]});

Result (Actual: red, expected: green):

-CREATE FUNCTION "accounting_ready" (in _o order)
+CREATE FUNCTION "accounting_ready" (in _o "order")
 RETURNS table( invoice boolean, usage boolean )
 LANGUAGE sql
 AS $$
	SELECT true, true
	FROM "order" o
	WHERE o.id = _o.id
$$
;

Here order is a table in the database

current workaround:

	$sqlt->add_procedure(
		name =>  'accounting_ready',
		parameters =>  [
-			{ argmode => 'in',  name => '_o',  type => 'order' },
+			{ argmode => 'in',  name => '_o',  type => '"order"' },
		],
		extra =>  {
			returns =>  { type => 'table( invoice boolean, usage boolean )' },
			definitions =>  [
				{ language  =>  'sql'  },
				{ quote => "\$\$\n",  body => <<'	FUNC' =~ s!^\t!!grm  =~ s!;\n!;/**/\n!grs  }
		SELECT true, true
		FROM "order" o
		WHERE o.id = _o.id
	FUNC
	]});
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