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

Select never finds if used not primary key #58

Closed
smallhive opened this issue Nov 4, 2015 · 4 comments
Closed

Select never finds if used not primary key #58

smallhive opened this issue Nov 4, 2015 · 4 comments
Assignees

Comments

@smallhive
Copy link

I have such space

localhost:3301> s

---
- index:
    0: &0
      unique: true
      parts:
      - type: NUM
        fieldno: 1
      id: 0
      space_id: 514
      name: primary
      type: HASH
    1: &1
      unique: false
      parts:
      - type: NUM
        fieldno: 3
      id: 1
      space_id: 514
      name: secondary
      type: TREE
    primary: *0
    secondary: *1
  on_replace: 'function: 0xb6e432a0'
  temporary: false
  id: 514
  engine: memtx
  enabled: true
  name: tester
  field_count: 0

I have script ( i want find all rows less 10):

<?php
$tarantool = new Tarantool("localhost", 3301);
for ($i = 0; $i < 1000; $i++)
{
    $tarantool->insert("tester", array($i, uniqid(), $i));
}

$row = $tarantool->select('tester', 10);
$rows = $tarantool->select('tester', 10, 'secondary', null, null, 3);

// ITER_LT = 3

Variable $rows is always empty array.

PHP 5.5.9-1ubuntu4.14
@rybakit
Copy link
Collaborator

rybakit commented Nov 4, 2015

Do you get results if you modify the following line:

$rows = $tarantool->select('tester', 10, 'secondary', 100, 0, 3);

?

rybakit pushed a commit to tarantool-php/client that referenced this issue Nov 4, 2015
@smallhive
Copy link
Author

Yes! The code returns rows, thanks! Could you change nulls to zeros in https://github.com/tarantool/tarantool-php-stubs?

@rybakit
Copy link
Collaborator

rybakit commented Nov 5, 2015

Providing null as a default argument value is a valid use case, so I think it's a bug of this client. /cc @bigbes

Could you change nulls to zeros in https://github.com/tarantool/tarantool-php-stubs?

Replacing nulls with zeros will not work, as these two lines are not the same:

$rows = $tarantool->select('tester', 10, 'secondary', 0, 0);
$rows = $tarantool->select('tester', 10, 'secondary');

Didn't test it, but I guess the first call will return an empty result, while the second one all matched records.

@smallhive
Copy link
Author

Thanks, i will write wrapper.

@rybakit rybakit reopened this Nov 6, 2015
@bigbes bigbes closed this as completed in 197358f Nov 6, 2015
@bigbes bigbes self-assigned this Jun 23, 2016
Totktonada added a commit that referenced this issue Mar 26, 2020
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.
Totktonada added a commit that referenced this issue Mar 28, 2020
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.
Totktonada added a commit that referenced this issue Mar 28, 2020
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants