Questions tagged [null]

Null means *nothing* or *unknown*, depending on context. Please use the "sql-null" tag for SQL specific questions.

"Null" has different meanings depending on context.

Set theory

Null is another name for the empty set, denoted by the symbol ∅. For this reason, some programming languages use null or nil for the empty list or empty tuple. Lisp uses nil to mean the empty list and the boolean value false.

Pointers and References

Null (or sometimes nil or None), in programming languages that support it, is the value of an uninitialized variable, a pointer that doesn't point to a meaningful memory address, or an object that fails to respond to any message.

Nullable references were invented by C.A.R. Hoare in 1965 as part of the Algol W language. Hoare later described his invention as a "billion-dollar mistake".

For more information, see Null pointer.

Agreeing with Hoare's sentiment, many languages don't have a special null value, choosing to use optional types instead.

Relational Databases

NULL as a special marker in SQL or a relational database stands in place of a value that is missing, or in a join means "no corresponding row." The operators IS NULL and IS NOT NULL are required for comparisons to a literal null: other comparisons between NULL and any value evaluate to "unknown."

For more information, see Null (SQL).

ASCII

Null or NUL is the name given to the character with ASCII code zero (0) - i.e. hex 00. In some languages, notably C, NUL is used to mark the end of a character string.

For more information, see Null character.

16208 questions
7
votes
1 answer

Newtonsoft.Json.JsonConvert.SerializeObject of BsonDocument containing null value fails with an InvalidCastException

The following test snippet demonstrates an InvalidCastException occurring in SerializeObject when an object value is null or even BsonNull.Value. If the value is changed to 42, serialization works fine. var bson = new BsonDocument { …
koan911
  • 360
  • 1
  • 3
  • 13
7
votes
2 answers

how to handle null in date field of postgresql

I have to ignore rows which have null in date column. How can I do it? select s."SR Closed Date"::date, s."Service Request Number", a."Activity ID" from sr_data_master s, activity_master a where s."Service Request Number" =…
Pallavi Singh
  • 175
  • 1
  • 1
  • 8
7
votes
3 answers

Is it good to use a default of NULL?

I have some columns that may contain data that is if the user wants to provide it. Example | Email | First Name | Last Name | Email - Required so column is set to NOT NULL - Default: None First Name - Not Required so column set to NULL - Default:…
PHPLOVER
  • 7,047
  • 18
  • 37
  • 54
7
votes
1 answer

Javascript memory impact of null vs undefined

I work in an area where memory utilization is very important to us, as we don't run on your classic web browsers / hardware. We use null quite a lot in our application, one thing that has not been clear to me is if null takes up more space than…
mrkgregg
  • 73
  • 1
  • 4
7
votes
1 answer

Null value returned to Apps Script webapp for a certain spreadsheet by server function

I am trying to return the data in the spreadsheet to an Apps Script published as a webApp. However, for one of my spreadsheets (link), the returned data is null. I logged the the data before returning to make sure that it isn't null, and I can see…
7
votes
3 answers

Short form for Java If statement returns NullPointerException when one of the returned objects is null

Why this code returns the error: java.lang.NullPointerException Object obj = null; Long lNull = null; Long res = obj == null ? lNull : 10L; But the following way works without any errors: Object obj = null; Long res = obj == null ? null : 10L;
Pavel Kataykin
  • 1,527
  • 15
  • 14
7
votes
3 answers

PostgreSQL JOIN without matching NULL values

I call this my "Battle of the Nulls", for I have struggled with this issue for years now. I have a large table (250,000+ rows, 100+ columns) named People, and another called Stuff, which may or may not contain a corresponding record. There are three…
Michael Sheaver
  • 2,059
  • 5
  • 25
  • 38
7
votes
1 answer

Should I add explicit null checks despite ReSharper [NotNull] annotations?

I'm using ReSharpers [NotNull] annotations like this: public void MyMethod([NotNull] string a) { if(a == null) // Warning: Expression is always false. { throw new ArgumentNullException(); } // ... } However, due to the…
Thomas Flinkow
  • 4,845
  • 5
  • 29
  • 65
7
votes
3 answers

Count Non Null values in column in PySpark

I have a dataframe which contains null values: from pyspark.sql import functions as F df = spark.createDataFrame( [(125, '2012-10-10', 'tv'), (20, '2012-10-10', 'phone'), (40, '2012-10-10', 'tv'), (None, '2012-10-10', 'tv')], …
newleaf
  • 2,257
  • 8
  • 32
  • 52
7
votes
2 answers

Non-initialized vs null values of reference types

Is there a difference between reference type variable being non initialized or having null value? I read somewhere that non-init means null but on other place I read something else. Thanks!
Lojol
  • 645
  • 3
  • 8
  • 15
7
votes
3 answers

NSError: Does using nil to detect Error actually turn off error reporting?

I got into the habit of coding my error handling this way: NSError* error = nil; NSDictionary *attribs = [[NSFileManager defaultManager] removeItemAtPath:fullPath error:&error]; if (error != nil) { DLogErr(@"Unable to remove file: error %@,…
EtienneSky
  • 1,156
  • 10
  • 17
7
votes
1 answer

Why do I get: null cannot be cast to non-null type android.widget.SearchView ?

I am trying to implement the "search widget" on my Menu Bar.. But I am getting the error: "null cannot be cast to non-null type android.widget.SearchView".. I did sme attempts to solve the problem, but no result.. Could you give me some hints?…
MisterNowhere
  • 605
  • 1
  • 6
  • 13
7
votes
3 answers

case null SQL Server 2008

How to check for null in case statement in SQL Server 2008
Rauf
  • 12,326
  • 20
  • 77
  • 126
7
votes
4 answers

SQL Server -- Handling null input in CLR User-Defined Function (UDF) with OnNullCall

I have a user-defined function in SQL Server (written in .NET) that cleans text. I'm wondering how to handle null input. Here is the function in C#: [Microsoft.SqlServer.Server.SqlFunction] public static SqlChars cleanEstActText(SqlChars input) { …
jtpereyda
  • 6,987
  • 10
  • 51
  • 80
7
votes
4 answers

Why would you set `null: false, default: ""` on a required DB column?

I'm building a Rails app with Devise for authentication, and its default DB migration sets the following columns: ## Database authenticatable t.string :email, null: false, default: "" t.string :encrypted_password, null: false, default:…
Ryan Lue
  • 916
  • 10
  • 29