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

unable to access results of custom functions when called from sql #3531

Closed
mattaylor opened this issue Feb 5, 2015 · 8 comments
Closed

unable to access results of custom functions when called from sql #3531

mattaylor opened this issue Feb 5, 2015 · 8 comments
Assignees

Comments

@mattaylor
Copy link
Contributor

It used to be (java 1.7) that functions like..

_1 = function() { return "hello" },
_2 = function() { return { greet: "hello" },
_3 = function() { return db.query("select from user limit 1");

Could be called from sql (or binary) using

select from _1()
select from _2()
select from _3()
etc..

and the response would be returned from sql as per the function.

Using 1.8 this is no longer the case, as although the functions are executed, the response values are not returned which effectively renders functions unusable unless invoked through the web api

This is possibly related to #3051

@mattaylor mattaylor changed the title unable to return from custom functions unable to access results of custom functions when called from sql Feb 5, 2015
@lvca lvca added the bug label Feb 5, 2015
@lvca lvca added this to the 2.1 milestone Feb 5, 2015
@lvca
Copy link
Member

lvca commented Feb 5, 2015

The problem seems the function name. If you call _1() as f1() works.

@lvca lvca closed this as completed Feb 5, 2015
@lvca lvca reopened this Feb 5, 2015
lvca added a commit that referenced this issue Feb 5, 2015
lvca added a commit that referenced this issue Feb 5, 2015
@lvca lvca closed this as completed Feb 5, 2015
@lvca lvca modified the milestones: 2.0.2 (hotfix), 2.1 Feb 5, 2015
@lvca lvca assigned lvca and unassigned luigidellaquila Feb 5, 2015
@lvca
Copy link
Member

lvca commented Feb 5, 2015

Fixed the problem with functions that starts with _

@mattaylor
Copy link
Contributor Author

Agreed that this the '_' is part of the problem, but there is more...

test1 = function() { return db.query("select from ouser limit 1") } 

sql> select from test1()

I would expect a user record to come back but in fact nothing does.

@lvca
Copy link
Member

lvca commented Feb 11, 2015

Testing it now...

@mattaylor
Copy link
Contributor Author

any joy?

@lvca
Copy link
Member

lvca commented Feb 12, 2015

Hey Mat. I tried and works. There was a typo on it. You should rather execute:

select test1()

@mattaylor
Copy link
Contributor Author

I did try this - but it does not return the document as expected - it just returns a temporary doc which must be expanded from a subselect

eg..

select expand(test1) from (select test1())

This is nasty.

@lvca
Copy link
Member

lvca commented Feb 12, 2015

This is how any function works, but distinct and expand.

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

No branches or pull requests

3 participants