Skip to content

SQL Server: Inserting Empty String in DateTime Column Becomes 1/1/1900 #279

@homestar9

Description

@homestar9

Imagine you want to save a struct like this to the database:

myFruit = {
	"name": "Banana",
	"color": "Yellow",
	"eatenDate": ""
};

qb.from( "fruit" ).insert( myFruit );

One would think that when you query the fruit you just inserted, the eatenDate value would be null. However, in MSSQL server if you insert an empty string (''), it will set the date to 1/1/1900.

Now, you could fix this by explicitly setting myFruit.eatenDate to { value="", null=true }. However, this extra step should be optional since most developers would expect QB to interpret an empty string as null when persisting the data to the database.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions