Bug: Using empty List/Set as query parameter in SQL prepared statement causes OStorageException

52 views
Skip to first unread message

Jean-Sebastien Lemay

unread,
May 13, 2015, 3:38:29 AM5/13/15
to orient-...@googlegroups.com
When using SQL prepared statements, passing an empty List or Set will cause an OStorageException to be raised (caused by a inner NoSuchElementException).

This will crash:
OrientGraph db = ...
String sql = "SELECT FROM MyUsers WHERE username NOT IN :usernames";
Map<String, Object> queryParams= new HashMap<>();            
queryParams
.put("usernames", new HashSet<String>());

Iterable<Vertex> results = ((Iterable<Vertex>)                    
    db
.command(new OSQLSynchQuery<>(sql))
       
.execute(queryParams));

Instead of crashing, I would've expected the output SQL command to be:
SELECT FROM MyUsers WHERE username NOT IN []

As soon as there is a value, the crash does not occur.
OrientGraph db = ...
String sql = "SELECT FROM MyUsers WHERE username NOT IN :usernames";
Map<String, Object> queryParams= new HashMap<>();            
queryParams
.put("usernames", new HashSet<String>() {{ add("test"); }});

Iterable<Vertex> results = ((Iterable<Vertex>)                    
    db
.command(new OSQLSynchQuery<>(sql))
       
.execute(queryParams));
(the above works fine)

Can this be fixed?

l.garulli

unread,
Sep 22, 2015, 2:51:17 AM9/22/15
to OrientDB
Tried with 2.1.2 and works. I've created a couple of new test cases for that.


Lvc@

Jean-Sebastien Lemay

unread,
Sep 22, 2015, 3:05:14 AM9/22/15
to orient-...@googlegroups.com
Thanks! Well done!

--

---
You received this message because you are subscribed to a topic in the Google Groups "OrientDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orient-database/Cs-xNsLMwvo/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages