From 243a991011170051fe23bc40da4a1f47ebd61bc6 Mon Sep 17 00:00:00 2001 From: Cnly Date: Mon, 5 Aug 2019 16:51:06 +0800 Subject: [PATCH] Fix nil may not be distinguished from empty slice in selectCurrentState --- syncapi/storage/filtering.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/syncapi/storage/filtering.go b/syncapi/storage/filtering.go index 75fc595e0..4ac88a219 100644 --- a/syncapi/storage/filtering.go +++ b/syncapi/storage/filtering.go @@ -22,6 +22,12 @@ import ( // https://matrix.org/docs/spec/client_server/r0.3.0.html#post-matrix-client-r0-user-userid-filter // to SQL wildcards that can be used with LIKE() func filterConvertTypeWildcardToSQL(values []string) []string { + if len(values) == 0 { + // Return nil instead of []string{} so IS NULL can work correctly when + // the return value is passed into SQL queries + return nil + } + ret := make([]string, len(values)) for i := range values { ret[i] = strings.Replace(values[i], "*", "%", -1)