Questions tagged [nullable]

The nullable tag is for issues relating to nullable members or types. A null is used to represent a missing or unknown value.

A data member is nullable if it can have the special value of NULL, instead of their common range of possible values. Nullable types are a feature of some statically-typed programming languages.

.NET

In , the built-in generic type System.Nullable<T> allows the programmer to use value types like int or DateTime with a value of null. Several .NET languages have a special syntax for declaring Nullable:

  • In , int? is an alias for System.Nullable<System.Int32>
  • In , Integer? is an alias for System.Nullable(Of System.Int32)

SQL

Null is a special marker used in SQL to indicate that data value do not exist in the database. Its proper use ensures various statistical aggregate functions perform correctly.

See more on Wikipedia.

D

The typecons module in package std has a templated struct - Nullable - for wrapping values types and allowing them to appear to have a null value (as in C#). Restriction is that the type must be able to be instantiated with T var or T var = T.init, where T represents the type being used.

Related tags

2417 questions
1
vote
3 answers

Why doesn't C# null check work with structs?

I usually check nullable types with if (foo is not null), and afterwards I can use foo like the non-null type. Why doesn't this work with structs? Even the ! operator does not help. Is this a bug or am I missing something? What's the shortest…
w123
  • 111
  • 2
1
vote
2 answers

How does Kotlin's data class copy idiom look for nullable types?

I have some code which looks like this, where param is of a data class type: val options = if (param.language == null) { param.copy(language = default()) } else { param } Now,…
Felix Dombek
  • 13,664
  • 17
  • 79
  • 131
1
vote
1 answer

Replace None in pandas data frame with Null

I have a pandas dataframe and I am getting None for many values. I need to write it to SQL server DB and want to update it with Null. How can i do that? I cannot use df.to_sql to write to DB, it is very slow. So I use pymsql. I convert the dataframe…
renjith
  • 111
  • 1
  • 9
1
vote
1 answer

nullable context doesn't work properly in c#

i am fully aware about nullabe context and how to deal with it in c#, even with this i have review this microsoft official tutorial and also this question on stackoverflow, but there is a thing that i really can not figure out why!!?? in a nullable…
1
vote
2 answers

Filter a Map with mutableList values

I have the following map object : var myStringMap = mapOf(10 to mutableListOf(),11 to mutableListOf(), 12 to mutableListOf()) I want to append files from a source to the corresponding key as follows : …
JPV
  • 1,079
  • 1
  • 18
  • 44
1
vote
1 answer

Nullable unique index in MongoDB

I am trying to insert documents in which a same property has null value while I have defined a unique index on it. I receive error because of same null values for that field. I used sparse: true, but it seems it works when target field does not…
weera
  • 884
  • 1
  • 10
  • 21
1
vote
1 answer

Warning: "Safe call on a non-null receiver will have nullable type in future releases" due to nullable variable in buildvariants

I'm developing an android app using Kotlin. I have two different build-variants - VariantA and VariantB - both containing a configuration-File: // VariantA object ConfigEnvironment { val SOME_PARAMETER: String? = null } // VariantB object…
m.reiter
  • 1,796
  • 2
  • 11
  • 31
1
vote
5 answers

What is the null value of Nullable(Of T)?

I have a nullable property, and I want to return a null value. How do I do that in VB.NET ? Currently I use this solution, but I think there might be a better way. Public Shared ReadOnly Property rubrique_id() As Nullable(Of Integer) …
thomasb
  • 5,816
  • 10
  • 57
  • 92
1
vote
1 answer

XML deserialize null elements?

trying to deserialize a Xml string, but always get problem for elements like these: My C# code snippet: [XmlRoot(ElementName = "Product", Namespace = "http://api.test.com/version/1", IsNullable = false)] public…
Paul L
  • 2,240
  • 5
  • 36
  • 55
1
vote
0 answers

Validate a (JSON-deserialized) DTO with Nullable Reference Types

Using Non-Nullable Reference Types is great, but there seems to be no built-in support for enforcing Non-Nullability when compiling a class with nullable=enable and using something like XML or JSON deserialization. I know it's just compiler…
AyCe
  • 727
  • 2
  • 11
  • 30
1
vote
0 answers

Importing CSV data with nullable DateTime values C#

I'm attempting to import a CSV file into a List in my code and initially, this was working fine, but I now need to modify this to allow null values for some of the DateTime fields (csvStartTime and csvEndTime). using System; using System.Linq; using…
Coder NT8
  • 11
  • 2
1
vote
2 answers

Compilation Check Plugin Framework to enforce no null return

Is there any framework / compiler plugin / static analysis tool for Java that Enforces that all return values are non-null unless they are explicitly marked as Nullable (via annotation or another way) in a given list of packages In essence that…
1
vote
1 answer

Enforce properties of an object not beeing null

My business logic receives often objects (DTOs) like the following one: public class CreateUserRequest { public string FirstName { get; set; } public string LastName { get; set; } public EMailAddress EMail { get; set; } } This is…
David Mason
  • 915
  • 1
  • 9
  • 27
1
vote
1 answer

fastparquet error when saving pandas df to parquet: AttributeError: module 'fastparquet.parquet_thrift' has no attribute 'SchemaElement

import pandas as pd from flatten_json import flatten actual_column_list = ["_id", "external_id", "email", "created_at","updated_at", "dob.timestamp", "dob_1.timestamp","column_10"] data = [{'_id': '60efe3333333445', 'external_id': 'ID2', 'dob':…
Dulshan
  • 31
  • 7
1
vote
1 answer

Non-nullable instance field 'id' must be initialized, Non-nullable instance field '_database' must be initialized. in flutter

could anyone help me with how to manage this problem? I am trying to code exactly likes the course's video, but I got this problem: I'm getting (Non-nullable instance field 'id' must be initialized. Non-nullable instance field 'miles' must be…
Ms one
  • 11
  • 2