Comments (5)
success
callback also receives null
always at the 1st argument.
It's a good idea to remove the unused callback argument error
, but my request to the idea is to make it optional, instead of just removing the error
, for the compatibility of users' code.
from presto-client-node.
My only thought to make it optional would be a flag to the Client
constructor to use or not use this behavior. I'm not sure there's a programmatic way to detect if an end user expects the error
argument or not in their callback.
Would you be fine with the flag being opt out, so that new users don't need to worry about the null
argument and existing users just need to toggle the flag on when upgrading, or for the flag to be opt in? My preference would be on making it opt out since:
- Ideally it'd be a flag could remove at some point in the future
- It makes it easier to make the TS types
For (2), if the behavior was opt in, then I'm not sure there's a way in TS to properly model this behavior that it renders it a lot less useful to me personally that I'd probably not bother with a PR to do this, and would then just leave it at the current status quo.
from presto-client-node.
callback.length
returns the number of arguments. So the callback caller can handle the difference of callback function arguments.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length
from presto-client-node.
This would only work in the case where a callback only has two arguments (just columns
) or that they always defined all arguments, which is almost certainly not true. JS does not care if you pass more arguments to a function than it allows for, e.g.:
const callback = () => {};
callback(1, 2, 3, 4, 5);
is perfectly valid JS.
As a further example, my current usage of the library looks like this:
client.execute({
query: statement,
state: (_, query_id) => {
// save query_id for later use
},
columns: (_, columns) => {
// save columns for later use
},
data: (_, data) => {
// buffer data until we hit success
},
error: (error) => {
// raise an error
},
success: () => {
// process our buffered data, return to caller
}
});
So in this case, the callback data.length === 2
, and it's not possible to tell in a user transparent way that I want the library to provide me the old style of callback ((error, data)
) or the new style ((data, columns)
).
from presto-client-node.
Oh, wow, I missed the case to have fewer arguments than documents intentionally.
If we have a flag to skip error
argument, it must be opt-in (its default value must be false) at first to not break compatibility of existing users' code.
My other idea is to have a set of callbacks with different names for fewer arguments.
from presto-client-node.
Related Issues (20)
- Cant get all the results of a query execute HOT 2
- Add support for Trino HOT 3
- Discussion: support kerberos authentication HOT 1
- Rewrite this library in TypeScript
- ReferenceError: client is not defined
- Support for promise in data_callback and success_callback methods
- How to provide certificate file (for secure connection) when connecting to presto? HOT 1
- How to define presto session properties?
- columns callback but no data callback HOT 1
- Unable to configure SQL preprocessing using 'prepares'. "message: 'Prepared statement not found: query0'" HOT 1
- [HELP]: Access Denied: User pbennett cannot impersonate user paul
- Query execution fails with multiple database connection HOT 1
- Real world example: datalake-graphql-wrapper
- Add CI tests for the library HOT 1
- TypeError if missing error callback when using success callback HOT 1
- Undefined error when nextUri request returns non-200 status code HOT 2
- Retrieving query status and cancelling query HOT 1
- How can I update values of particular records? HOT 1
- nextUri can return 301 redirect due to https/http mismatch HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from presto-client-node.