Different behavior between mgconsole and Memgraph Lab when query returns Null

Hi! In testing some queries related to this topic I found a different behavior in mgconsole compared to Memgraph Lab:

  1. Load an empty database with example data:
CREATE (u:User{name: 'user1'})
CREATE (:Movie{title: 'The Matrix'})<-[:created]-(u)
CREATE (:Movie{title: 'The Avengers'})
  1. Perform a query that will return Null
// 'The Avengers' doesn't have a user attached, so u.name should return `Null`
MATCH (m:Movie)
OPTIONAL MATCH (m)-[:created]-(u:User)
RETURN m.title, u.name
  1. Results:

Memgraph Lab output:
TypeError: Cannot read property 'class' of null

mgconsole output:

memgraph> MATCH (m:Movie)
       -> OPTIONAL MATCH (m)-[:created]-(u:User)
       -> RETURN m.title, u.name;
+----------------+----------------+
| m.title        | u.name         |
+----------------+----------------+
| "The Matrix"   | "user1"        |
| "The Avengers" | Null           |
+----------------+----------------+
2 rows in set (0.000 sec)
memgraph>

Screenshot:

Should Memgraph Lab be able to show the Null result? Or maybe I have a setting wrong? A workaround I’ve been using in Lab is to change the query to:

MATCH (m:Movie)
OPTIONAL MATCH (m)-[:created]-(u:User)
RETURN m.title, coalesce(u.name, '')

returns:

#	m.title	          coalesce(u.name, '')	
1	The Matrix        user1
2	The Avengers

and then removing the coalesce when I run the query from another client.

Memgraph Lab version: 1.3.0
Memgraph version: v1.6.0-community
OS: Windows 10

Thanks! :slight_smile:

Hi there,

This is definitely a bug in Memgraph Lab because Lab tries to color the response values depending on the class, but there is nothing for a Null. Thanks for pointing that out, we will fix it!

Btw, the workaround you used is awesome! :wink:

1 Like