-
Notifications
You must be signed in to change notification settings - Fork 217
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
Extend the Query Result Mask #371
Comments
Updated type in branch driver-7.x: /**
* @enum {number}
* @alias queryResult
* @readonly
* @description
* _Query Result Mask._
*
* Binary mask that represents the result expected from queries.
* It is used by generic {@link Database#query query} method, as well as method {@link Database#func func}.
*
* The mask is always the last optional parameter, which defaults to `queryResult.any`.
*
* Any combination of flags is supported.
*
* The type is available from the library's root: `pgp.queryResult`.
*
* @see {@link Database#query Database.query}, {@link Database#func Database.func}
*/
const queryResult = {
/** Expecting a single result-set, with a single row in it. */
one: 1,
/** Expecting a single result-set, with one or more rows in it. */
many: 2,
/** Expecting a single result-set, with no rows in it. */
none: 4,
/** Expecting multiple result-sets. */
multi: 8,
/** No expectation as to the data returned. */
any: 15 //= one | many | none | multi
}; This is a major breaking change, as it completely changes the logic for the query-result mask. |
Masks vs ResultAll combinations of masks as can be passed into methods
Note that Methods vs ResultWe only have methods that use result mask combinations that make practical sense, even though you are free to use any combination via methods
The only methods not listed here are |
Implemented, pending tests + documentation. |
I'm not sure about the |
@dmfay The reason I did it this way is to have methods that can access the original data sets either as arrays or as It is of a compromise. I was thinking - how to get all the basics available and not to over-design this thing. We already have so many methods for the mask, even though it is all logical, I'd love keeping it simple. Anyhow, any suggestions are welcome! 😉 |
ah, I got you. It is a bit up for debate whether a constraint is on one or all resultsets when you bring Looking a bit closer at the methods, I'm more of the 'if a result can ever iterate, it should always iterate' school of thought. I'd never use |
I agree, the previous method Also method I just want a set of methods that are logical, consistent with their naming and the logical mask. This is somewhat challenging. May be I should reduce the methods to a bare minimum... somehow. @dmfay I am open to suggestions 😉 My biggest concern right now - the default mask for method |
As far as reducing the method count: out of the first seven ( I'm not sure
But fundamentally, I have a hard time envisioning a use case in which I'm emitting a query and don't know up front whether it comprises one or several individual statements. If I did have that kind of situation, I think it'd be reasonable to just use |
queryResult mask needs to be revised to allow multi-result sets, as supported by
node-postgres
v7.New mask
multi
is to be added.The text was updated successfully, but these errors were encountered: