Which is exactly the desired behavior, an empty collection is expected an empty collection not null.
If you want null you can use your own API and elide away the ARRAY[] syntax in favor of null:
$”{PgSql.ToArray(array)}”
Edit: since it results in nicer typed code the new PgSql.Array() API is now available from v5.8.1 where you can use the same API for value type or strings alike, e.g:
$”{PgSql.Array(1,2,3)}”
var strings = new[]{ "A","B","C" };
$”{PgSql.Array(strings)}”
Which will make the TechStacks code above nicer, string[]:
q.And($"{PgSql.Array(labelSlugs)} && labels"); //equivalent to:
q.And($"ARRAY[{new SqlInValues(labelSlugs).ToSqlInString()}] && labels");
And for int[]:
q.And($"{PgSql.Array(request.AnyTechnologyIds)} && technology_ids") //equivalent
var techIds = request.AnyTechnologyIds.Join(",")
q.And($"ARRAY[{techIds}] && technology_ids")
If you want null instead of an empty array you can use the overload:
PgSql.Array(new string[0], nullIfEmpty:true) //= null
PgSql.Array(new[]{"A","B","C"}, nullIfEmpty:true) //= ARRAY['A','B','C']