Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

NULL is not printed in the resulting table #779

Closed
zwcn opened this issue Jul 1, 2019 · 1 comment · Fixed by #783
Closed

NULL is not printed in the resulting table #779

zwcn opened this issue Jul 1, 2019 · 1 comment · Fixed by #783
Assignees
Labels
bug Something isn't working

Comments

@zwcn
Copy link

zwcn commented Jul 1, 2019

Hi,

When I used mysql client to connect the SQL server, I got the following table in which there were some empty fields that were supposed to be printed as NULL.

What I got:

$ mysql -h 127.0.0.1 -u root
mysql> select * from tbl where timestamp = 3;
+--------------+-----------+-----------+-------------+
| id           | timestamp | col1      | col2       |
+--------------+-----------+-----------+-------------+
| id1          |         3 |           |           3 |
| id2          |         3 |           |           3 |
| id3          |         3 |         3 |             |
+--------------+-----------+-----------+-------------+
3 rows in set (0.51 sec)

What I expect:

$ mysql -h 127.0.0.1 -u root
mysql> select * from tbl where timestamp = 3;
+--------------+-----------+-----------+-------------+
| id           | timestamp | col1      | col2        |
+--------------+-----------+-----------+-------------+
| id1          |         3 |   NULL    |           3 |
| id2          |         3 |    NULL   |           3 |
| id3          |         3 |         3 |    NULL     |
+--------------+-----------+-----------+-------------+
3 rows in set (0.51 sec)

It seems to me that in https://github.com/src-d/go-mysql-server/pull/753/files#diff-654bac6a55597b15c4a5d404095b4e69R306, shouldn't we handle both nil and nullT? For example:

if _, ok := v.(nullT); ok || v == nil {
  return sqltypes.NULL, nil
}
@erizocosmico
Copy link
Contributor

I don't think it's related to that PR. nullT is a type, and that function never receives a type, only a value. The value of a nullT type is always nil.

Not printing null is a bug, though.

@erizocosmico erizocosmico added the bug Something isn't working label Jul 2, 2019
@erizocosmico erizocosmico self-assigned this Jul 3, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants