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

Overloaded postgres routine missing schema qualification on parameter cast in 3.9.0 #5798

Closed
dleary opened this issue Jan 19, 2017 · 3 comments

Comments

@dleary
Copy link

dleary commented Jan 19, 2017

If a postgres function is overloaded with a schema specific parameter type in one signature, the generated invocation sql is missing a schema qualifier. E.g. given:

create schema foo;
create type foo.bartype as enum ('one', 'two');

create function foo.function(arg1 int) returns text
as $$
begin
  return cast(arg1 as text);
end;
$$ language plpgsql;

create function foo.function(arg1 foo.bartype) returns text
as $$
begin
  return cast(arg1 as text);
end;
$$ language plpgsql;

Invoking the second signature generates something along the lines:
select "function" from "foo"."function"("arg1" := cast($1::"fb"."bartype" as bartype)
But the type named in the cast needs to be qualified relative to schema foo.
Worked ok in 3.8.6.

@lukaseder
Copy link
Member

Thank you very much for reporting. I wonder why the second (outer) cast is added, the first one (inner) ought to be sufficient

@dleary
Copy link
Author

dleary commented Jan 20, 2017

Agreed. The workaround I've used is to rename the second function. Without the overloading the generated sql is fine. Haven't captured the good sql, however.

@lukaseder
Copy link
Member

With jOOQ 3.18, I cannot reproduce this anymore. The logged SQL is:

14:53:57,562 DEBUG [LoggerListener                ] - Executing query          : select "function" from "foo"."function"("arg1" := cast(? as int)) -- SQL rendered with a free trial version of jOOQ 3.18.0-SNAPSHOT
14:53:57,564 DEBUG [LoggerListener                ] - -> with bind values      : select "function" from "foo"."function"("arg1" := cast(1 as int))
14:53:57,608 DEBUG [LoggerListener                ] - Fetched result           : +--------+
14:53:57,608 DEBUG [LoggerListener                ] -                          : |function|
14:53:57,608 DEBUG [LoggerListener                ] -                          : +--------+
14:53:57,609 DEBUG [LoggerListener                ] -                          : |1       |
14:53:57,609 DEBUG [LoggerListener                ] -                          : +--------+
14:53:57,609 DEBUG [LoggerListener                ] - Fetched row(s)           : 1
14:53:58,133 DEBUG [LoggerListener                ] - Executing query          : select "function" from "foo"."function"("arg1" := cast(cast(? as "foo"."bartype") as "foo"."bartype")) -- SQL rendered with a free trial version of jOOQ 3.18.0-SNAPSHOT
14:53:58,135 DEBUG [LoggerListener                ] - -> with bind values      : select "function" from "foo"."function"("arg1" := cast(cast('one' as "foo"."bartype") as "foo"."bartype"))
14:53:58,138 DEBUG [LoggerListener                ] - Fetched result           : +--------+
14:53:58,138 DEBUG [LoggerListener                ] -                          : |function|
14:53:58,138 DEBUG [LoggerListener                ] -                          : +--------+
14:53:58,138 DEBUG [LoggerListener                ] -                          : |one     |
14:53:58,138 DEBUG [LoggerListener                ] -                          : +--------+
14:53:58,138 DEBUG [LoggerListener                ] - Fetched row(s)           : 1

I remember having fixed related issues recently. It's also integration tested now.

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

No branches or pull requests

2 participants