Also, passing in a number when creating a query just works, despite the type being a string.
const params: Partial<IWriteQuery> = {
model: ...,
view: ...,
fields: [...],
// @ts-ignore
limit: 3 // <--- this should be a string according to types but a number works fine
};
const query = await sdk.ok(sdk.create_query(params));
const runParams: IRequestRunQuery = {
query_id: 1,
}
const result = await sdk.ok(sdk.run_query(runParams));
What's going on here? Why is limit a string anywhere at all?
Problem
The
limit
property is defined as a string for theWriteQuery
type:https://github.com/looker-open-source/sdk-codegen/blob/main/packages/sdk/src/4.0/models.ts#L13800
Which is used for creating a query:
https://github.com/looker-open-source/sdk-codegen/blob/main/packages/sdk/src/4.0/methodsInterface.ts#L6373
But
limit
is defined as a number for theIRequestRunQuery
type:https://github.com/looker-open-source/sdk-codegen/blob/main/packages/sdk/src/4.0/models.ts#L8583
Which is used for running a previously created query:
https://github.com/looker-open-source/sdk-codegen/blob/main/packages/sdk/src/4.0/methodsInterface.ts#L6412
Discussion
It's confusing why one needs to pass
"3"
when creating a query but3
when running it.When you create and run a query at once (i.e. run it inline):
https://github.com/looker-open-source/sdk-codegen/blob/main/packages/sdk/src/4.0/methodsInterface.ts#L6479
You also need to use a number:
https://github.com/looker-open-source/sdk-codegen/blob/main/packages/sdk/src/4.0/models.ts#L8437
Also, passing in a number when creating a query just works, despite the type being a string.
What's going on here? Why is
limit
a string anywhere at all?