diff --git a/modules/conop/src/compound_lib.cc b/modules/conop/src/compound_lib.cc index c84b0e9b7837036a66c737fc86c93d9d929bcf93..6782828f33bf2cca80cefed5c47586562778f9ea 100644 --- a/modules/conop/src/compound_lib.cc +++ b/modules/conop/src/compound_lib.cc @@ -264,13 +264,23 @@ void CompoundLib::AddCompound(const CompoundPtr& compound) sqlite3_bind_text(stmt, 6, compound->GetFormula().c_str(), compound->GetFormula().length(), NULL); Date crea_date=compound->GetCreationDate(); + if (crea_date == Date()) { + sqlite3_bind_null(stmt, 7); + } + else { + crea_date_str=crea_date.ToString(); + sqlite3_bind_text(stmt, 7, crea_date_str.c_str(), crea_date_str.length(), + NULL); + } Date modi_date=compound->GetModificationDate(); - crea_date_str=crea_date.ToString(); - modi_date_str=modi_date.ToString(); - sqlite3_bind_text(stmt, 7, crea_date_str.c_str(), crea_date_str.length(), - NULL); - sqlite3_bind_text(stmt, 8, modi_date_str.c_str(), modi_date_str.length(), - NULL); + if (modi_date == Date()) { + sqlite3_bind_null(stmt, 8); + } + else { + modi_date_str=modi_date.ToString(); + sqlite3_bind_text(stmt, 8, modi_date_str.c_str(), modi_date_str.length(), + NULL); + } sqlite3_bind_text(stmt, 9, compound->GetName().c_str(), compound->GetName().length(), NULL); sqlite3_bind_text(stmt, 10, compound->GetInchi().c_str(), diff --git a/modules/io/src/mol/chemdict_parser.cc b/modules/io/src/mol/chemdict_parser.cc index 382a983affb24a05ca52ad68c899c558d7fe66a4..3f97a49b5207db5d8d6b17dbdf13fffd8da50c3c 100644 --- a/modules/io/src/mol/chemdict_parser.cc +++ b/modules/io/src/mol/chemdict_parser.cc @@ -155,18 +155,24 @@ void ChemdictParser::OnDataItem(const StarDataItem& item) compound_->SetObsolete(true); } } else if (item.GetName()==StringRef("pdbx_replaced_by", 16)) { - String replaced_by = item.GetValue().str(); - if (replaced_by != "?") { - compound_->SetReplacedBy(replaced_by); + StringRef replaced_by = item.GetValue(); + if (! IsUndefined(replaced_by)) { + compound_->SetReplacedBy(replaced_by.str()); } } else if (item.GetName()==StringRef("one_letter_code", 15)) { if (item.GetValue().length()==1) { compound_->SetOneLetterCode(item.GetValue()[0]); } - } else if (item.GetName()==StringRef("pdbx_initial_date", 17)) { - compound_->SetCreationDate(Date::FromString(item.GetValue())); + } else if (item.GetName()==StringRef("pdbx_initial_date", 17)) { + StringRef pdbx_initial_date = item.GetValue(); + if (! IsUndefined(pdbx_initial_date)) { + compound_->SetCreationDate(Date::FromString(pdbx_initial_date)); + } } else if (item.GetName()==StringRef("pdbx_modified_date", 18)) { - compound_->SetModificationDate(Date::FromString(item.GetValue())); + StringRef pdbx_modified_date = item.GetValue(); + if (! IsUndefined(pdbx_modified_date)) { + compound_->SetModificationDate(Date::FromString(pdbx_modified_date)); + } } } else if (item.GetName()==StringRef("atom_id", 7)) { atom_.name=item.GetValue().str();