-
Notifications
You must be signed in to change notification settings - Fork 24
select() does not allow null offset parameter in the strict types mode #154
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
Comments
Well, the current behavior does not contradict the documentation, it is stated that the offset is an integer number, to support both So I don't know whether this issue is a bug or a feature request. :) |
Cited from the documentation:
Should all parameters except the first one be described as |
Since php doesn't support named arguments, $tarantool->select('foo', null, null, null, null, Tarantool::ITERATOR_EQ); vs $tarantool->select('foo', [], 0, PHP_INT_MAX, 0, Tarantool::ITERATOR_EQ); But I don't have a strong opinion on that, both options look ugly to me :) |
No-no, I meant whether you suggest to update README with the change of the behaviour and, if so, how exactly? |
public Tarantool::select(
int|string $space [,
int|array|null $key = [] [,
int|string|null $index = 0 [, // does it support named indices yet?
int|null $limit = PHP_INT_MAX [,
int|null $offset = 0 [,
int|string|null $iterator = Tarantool::ITERATOR_EQ|Tarantool::ITERATOR_ALL
] ] ] ] ] ) : array where
WDYT? |
When PHP strict types mode is enabled (`declare(strict_types=1);`) the `offset` parameter passed as `null` to select() method does not pass validation. It looks quite natural to accept `null` here, because when the parameter is omitted the default value (zero) is assumed. A user may want to set the next parameter (`iterator`) and left `offset` to be default, so (s)he'll use `null`. The similar change was made for the `limit` in the scope of #58. After this commit `offset` and `limit` parameters behave in the same way. The functionality is already covered by the test suite (DMLTest::test_14_select_limit_defaults()), but the problem was not catched until now, because strict types mode is not enabled in tests. It'll be enabled in a following commit and the problem will be actually tested. Fixes #154.
It is the rule of thumb to run tests in the strict types mode, because it may reveal subtle problems. See #154 for example. Updated the test suite to cast tarantool port (acquired from PRIMARY_PORT environment variable) from string to int. Aside of this, raise an error when the port is not set: it'll allow to fail fast and provide a good diagnostic when a configuration problem occurs.
When PHP strict types mode is enabled (`declare(strict_types=1);`) the `offset` parameter passed as `null` to select() method does not pass validation. It looks quite natural to accept `null` here, because when the parameter is omitted the default value (zero) is assumed. A user may want to set the next parameter (`iterator`) and left `offset` to be default, so (s)he'll use `null`. The similar change was made for the `limit` in the scope of #58. After this commit `offset` and `limit` parameters behave in the same way. The functionality is already covered by the test suite (DMLTest::test_14_select_limit_defaults()), but the problem was not catched until now, because strict types mode is not enabled in tests. It'll be enabled in a following commit and the problem will be actually tested. Fixes #154.
It is the rule of thumb to run tests in the strict types mode, because it may reveal subtle problems. See #154 for example. Updated the test suite to cast tarantool port (acquired from PRIMARY_PORT environment variable) from string to int. Aside of this, raise an error when the port is not set: it'll allow to fail fast and provide a good diagnostic when a configuration problem occurs.
When PHP strict types mode is enabled (`declare(strict_types=1);`) the `offset` parameter passed as `null` to select() method does not pass validation. It looks quite natural to accept `null` here, because when the parameter is omitted the default value (zero) is assumed. A user may want to set the next parameter (`iterator`) and left `offset` to be default, so (s)he'll use `null`. The similar change was made for the `limit` in the scope of #58. After this commit `offset` and `limit` parameters behave in the same way. The functionality is already covered by the test suite (DMLTest::test_14_select_limit_defaults()), but the problem was not catched until now, because strict types mode is not enabled in tests. It'll be enabled in a following commit and the problem will be actually tested. Fixes #154.
It is the rule of thumb to run tests in the strict types mode, because it may reveal subtle problems. See #154 for example. Updated the test suite to cast tarantool port (acquired from PRIMARY_PORT environment variable) from string to int. Aside of this, raise an error when the port is not set: it'll allow to fail fast and provide a good diagnostic when a configuration problem occurs.
Fixed in |
How to reproduce:
The documetation states that $offset parameter is 0 and it is quite natural to expect that when null is passed it'll be considered as zero offset.
See the similar #58.
The text was updated successfully, but these errors were encountered: