Commit 2ca09707 authored by phenigma's avatar phenigma

Refs #2648 - ensure that NOT NULL varchar fields have a default or db import will fail.

parent 941b2081
......@@ -951,6 +951,7 @@ void Repository::ImportTable(string sTableName,SerializeableStrings &str,size_t
sPrimaryKey += ( sPrimaryKey.length( ) ? "," : "" ) + string( "`" ) + sField + "`";
sSQL << "`" << sField << "` " << sType
<< ( sNULL!="YES" ? " NOT NULL " : "" );
if( sDefault.length( ) )
{
string sQuotedDefault;
......@@ -965,6 +966,14 @@ void Repository::ImportTable(string sTableName,SerializeableStrings &str,size_t
sSQL << " default " << ( sDefault==NULL_TOKEN ? "NULL" : sQuotedDefault );
}
// need to ensure that NOT NULL varchar fields have a default or db import will fail.
else
{
if( sNULL!="YES" && sType.find("varchar")!=string::npos )
{
sSQL << " default ''";
}
}
sSQL << " " << sExtra;
}
if( sPrimaryKey.length( ) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment