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

Make it possible to registerFunction for a version of generate_series #383

Open
marcus13371337 opened this issue Mar 2, 2024 · 1 comment

Comments

@marcus13371337
Copy link

Consider the following query:

SELECT * FROM generate_series(1, 5)
 generate_series
-----------------
               1
               2
               3
               4
               5
(5 rows)

I'm having a hard time registering a function that could handle this scenario. What I've tried:

 db.public.registerFunction({
    name: "generate_series",
    args: [DataType.integer, DataType.integer],
    returns: DataType.integer, // Should be typed to array somehow I guess?
    implementation: (from: any, to: any) => {
      const start = parseInt(from);
      const stop = parseInt(to);

      const result = [];
      for (let i = start; i <= stop; i++) {
        result.push(i);
      }

      return result;
    },
  });

Is this possible already? Or are there any missing functionalities in the library to get this to work?

@mattiasahlsen
Copy link

This would be a really nice feature, I need this as well

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

2 participants