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
1 answer

@Nullable in Spring 5 is annotated with @Nonnull

I just updated my project to use Spring Boot 2.0.3 with Spring Framework 5.0.7. And now I see that some parameters in methods of MessageSource are annotated with Spring's shiny new @Nullable annotation. But due to this annotation, IDEA 14 says that…
stepio
  • 865
  • 2
  • 9
  • 22
1
vote
3 answers

Assigning value to member of nullable struct in C#

In C#, I have a struct like this: public struct Slab { public float[] sizeM; public string textureSrc; //more members, not relevant here... } And another like this: public struct Tombstone { public Slab mainSlab; public Slab?…
dukc
  • 121
  • 1
  • 9
1
vote
1 answer

What is difference between nullable datetime property and its field?

I have a desktop app which uses Serialization and saves data before closing and load same data from file using this code: IFormatter formatter = new BinaryFormatter(); var array = (MyClass[])formatter.Deserialize(stream); MyClass has a datime…
onur demir
  • 421
  • 7
  • 13
1
vote
1 answer

In USQL, I keep getting conversion error for NULL even though I am using the nullable type e.g. int?, datetime? etc.

When I change the type to string, I am fine. But, when I use int?, datetime? etc, sometimes it accepts NULL and sometimes, it fails with the error. "Problem while converting input string '"NULL"' to proper type."
Vanamali
  • 47
  • 5
1
vote
2 answers

Getting a non-NULL-able warning when using SELECT * INTO

When I execute the following proc, I get this warning: Attempting to set a non-NULL-able column's value to NULL. USE [DbTwo] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO alter proc [dbo].[TEST_warning_proc] as IF…
Eliezer
  • 429
  • 1
  • 9
  • 20
1
vote
0 answers

How to declare a nullable array type in C#?

I am working with multi dimensional arrays that can store null values. I am declaring one of my array as follows : public Size?[,] CellSize { get; set; } However when I compile it, StyleCop gives an error SA0102 : CSharp.CsParser : A syntax error…
Jasmeet
  • 1,315
  • 11
  • 23
1
vote
2 answers

Doctrine boolean type can't be set to false

I can't set false value to an entity column which type is boolean. /** * @ORM\Column(type="boolean") */ private $isActive; Sending JSON: {myEntity: {isActive: false}} ...will cause: Integrity constraint violation: 1048 Column 'is_active' cannot…
undefinedman
  • 620
  • 1
  • 11
  • 25
1
vote
1 answer

Android Kotlin cancel callback

still very new to Kotlin, i'm trying not to call my callback if my activity is null. Let me explain, i have my DataManager that perform async work on some data: fun performWork(callback: ((param1: T, param2) -> Unit)?) { // ... async work with…
user2434385
  • 281
  • 1
  • 3
  • 16
1
vote
3 answers

Subscribe to events of a nullable class

I'm subscribing to an event generated by a class that might be null as follows: if (eventGeneratingClass != null) eventGeneratingClass.myEvent += myHandler; In the event generating class a construct like myEvent?.Invoke(this, new…
Lanting
  • 3,060
  • 12
  • 28
1
vote
1 answer

Implicit conversion from Nullable

I want to create a class like Nullable except for the moment that it could work with classes and structures: public class MyWrapper { public MyWrapper(T value) { Value = value; } public T Value { get; set; } } Then I…
1
vote
0 answers

Non annotated methos as nullable by default

Is it possible to configure the IntelliJ or maybe the NullAway to consider non annotated method as Nullable by default? e.g. The following method: context.getResources().getString(R.string.app_name); The getResources is not annotated as nullable or…
ademar111190
  • 14,215
  • 14
  • 85
  • 114
1
vote
1 answer

Error System.Nullable'1 automapper

i have entity class, pinjaman_DataEntities, that has 4 properties. public string appl_no { get; set; } public string reff_number { get; set; } public string cust_name { get; set; } public string merchant_id { get; set; } and i have a database…
M. Fahrizal
  • 15
  • 10
1
vote
1 answer

Issue with Umbraco Service - "Nullable object must have value"

We're implementing different Umbraco service using ApplicationContext to pull data from Umbraco backend. It always give null in return or gives exception of "Nullable object must have value" while calling the service method itself. This is might…
Developer
  • 46
  • 5
1
vote
3 answers

C# What type should I cast here?

I have a portion of code which calculates a new balance by reading from a database all prior charges and payments and then adding the new amount that's going to be charged to the balance. It was working fine with values that I'd hand planted into…
LennyLen
  • 13
  • 2
1
vote
1 answer

How can I have value types that map to nullable database columns in Entity Framework?

I have the following Entity model: public class Todo { [Required] public int ID { get; set; } public int OrderId { get; set; } //Not required public string Description { get; set; } public bool Finished { get; set; } …
user547311
  • 33
  • 1
  • 4