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

COUNT return nothing when no line match the criteria #8280

Closed
jxerome opened this issue May 21, 2018 · 1 comment
Closed

COUNT return nothing when no line match the criteria #8280

jxerome opened this issue May 21, 2018 · 1 comment
Assignees
Labels
Milestone

Comments

@jxerome
Copy link

jxerome commented May 21, 2018

OrientDB Version: 3.0.1, 3.0.0RC2

Java Version: 1.8.0_162

Java(TM) SE Runtime Environment (build 1.8.0_162-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)

OS: MacOSX 10.13.4

Expected behavior

When counting elements of a class with a restriction

select count(*) from foo where name = 'bar'

I expect to get a single result with the count value event if no foo object has the name 'bar'.
In this case, the value of count should be 0.

Actual behavior

When the restriction is empty, count has no result at all.

Note, when there is no restriction but the class is empty, the query bahave has expected.

Note: the problem seams to come from a premature optimisation of the query plan that dump the result when the restriction is empty.

Steps to reproduce

Here is a scenario from the console 3.0.1. The same behavior happens in the java driver.

orientdb> create database memory:test

Creating database [memory:test] using the storage type [MEMORY]...
Database created successfully.

Current database is: memory:test
orientdb {db=test}> create class a

Class created successfully.

orientdb {db=test}> create property a.name string

Property created successfully.

orientdb {db=test}> select count(*) from a

+----+--------+
|#   |count(*)|
+----+--------+
|0   |0       |
+----+--------+

1 item(s) found. Query executed in 0.004 sec(s).

orientdb {db=test}> insert into a (name) values ('a')

Inserted record '[a#25:0{name:a} v1]' in 0,009000 sec(s).

orientdb {db=test}> insert into a (name) values ('b')

Inserted record '[a#26:0{name:b} v1]' in 0,001000 sec(s).

orientdb {db=test}> insert into a (name) values ('c')

Inserted record '[a#27:0{name:c} v1]' in 0,001000 sec(s).

orientdb {db=test}> select count(*) from a

+----+--------+
|#   |count(*)|
+----+--------+
|0   |3       |
+----+--------+

1 item(s) found. Query executed in 0.005 sec(s).
orientdb {db=test}> select count(*) from a where name = 'a'

+----+--------+
|#   |count(*)|
+----+--------+
|0   |1       |
+----+--------+

1 item(s) found. Query executed in 0.013 sec(s).
orientdb {db=test}> select count(*) from a where name = 'd'


0 item(s) found. Query executed in 0.002 sec(s).
orientdb {db=test}>

The last command should return an item with 0.

@luigidellaquila
Copy link
Member

Hi @jxerome

I just pushed a fix to develop branch, it will be released with v 3.0.3

Thanks

Luigi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants