[lxc-devel] [lxd/master] Fix selecting NULL description columns

freeekanayaka on Github lxc-bot at linuxcontainers.org
Sat Aug 24 14:40:22 UTC 2019


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 361 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20190824/fdf78679/attachment.bin>
-------------- next part --------------
From aff405522dcbfbf6c85b5802bb0cf1052ae2c5d2 Mon Sep 17 00:00:00 2001
From: Free Ekanayaka <free.ekanayaka at canonical.com>
Date: Sat, 24 Aug 2019 16:39:22 +0200
Subject: [PATCH] Fix selecting NULL description columns

Signed-off-by: Free Ekanayaka <free.ekanayaka at canonical.com>
---
 lxd/db/cluster/update.go      | 2 +-
 lxd/db/cluster/update_test.go | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/lxd/db/cluster/update.go b/lxd/db/cluster/update.go
index b4bbce69a0..93925a6f94 100644
--- a/lxd/db/cluster/update.go
+++ b/lxd/db/cluster/update.go
@@ -165,7 +165,7 @@ CREATE VIEW instances_snapshots_devices_ref (
 	}
 
 	stmt, err := tx.Prepare(`
-SELECT id, name, type, creation_date, stateful, description, expiry_date FROM instances
+SELECT id, name, type, creation_date, stateful, coalesce(description, ''), expiry_date FROM instances
 `)
 	if err != nil {
 		return errors.Wrap(err, "Failed to prepare instances query")
diff --git a/lxd/db/cluster/update_test.go b/lxd/db/cluster/update_test.go
index 6937d0dc21..c620f2c56a 100644
--- a/lxd/db/cluster/update_test.go
+++ b/lxd/db/cluster/update_test.go
@@ -502,7 +502,7 @@ func TestUpdateFromV15(t *testing.T) {
 
 		// Insert an instance.
 		_, err = db.Exec(`
-INSERT INTO instances VALUES (1, 1, 'eoan', 2, 0, 0, ?, 0, ?, 'Eoan Ermine', 1, ?)
+INSERT INTO instances VALUES (1, 1, 'eoan', 2, 0, 0, ?, 0, ?, NULL, 1, ?)
 `, time.Now(), time.Now(), time.Now())
 		require.NoError(t, err)
 		_, err = db.Exec("INSERT INTO instances_config VALUES (1, 1, 'key', 'value2')")


More information about the lxc-devel mailing list