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

Support custom conversion of result data #123

Open
jraymakers opened this issue Jan 27, 2025 · 0 comments
Open

Support custom conversion of result data #123

jraymakers opened this issue Jan 27, 2025 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@jraymakers
Copy link
Contributor

Result data can be converted to JSON-serializable JS objects using any of the variants of get...Json (e.g. getRowObjectsJson).

However, it would be useful to be able to specify custom conversions. This is already somewhat supported at the chunk level through the various convert... methods and the DuckDBValueConverter interface (and indeed this is what the get...Json methods use). But it would be more convenient to have top-level methods on DuckDBResult and DuckDBResultReader to get data using a custom converter.

Additionally, it would be helpful to be able to specify custom conversion by starting from an existing, library-supplied converter and only specifying the (usually few) differences desired.

One example of doing this is the pg-promise API:

function setPgParserTypes() {
  // see https://stackoverflow.com/questions/39168501/pg-promise-returns-integers-as-strings
  pgp().pg.types.setTypeParser(TypeId.INT8, parseInt);
  pgp().pg.types.setTypeParser(TypeId.FLOAT8, parseFloat);
  pgp().pg.types.setTypeParser(TypeId.NUMERIC, parseFloat);
}

(From https://stackoverflow.com/questions/39168501/pg-promise-returns-integers-as-strings)

@jraymakers jraymakers self-assigned this Jan 27, 2025
@jraymakers jraymakers added the enhancement New feature or request label Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant