Commit 9a07f30b authored by Olivier Bertrand's avatar Olivier Bertrand

Fix some Json and Bson bugs

parent 1d627ce4
......@@ -784,6 +784,12 @@ PVAL BCUTIL::MakeBson(PGLOBAL g, PBVAL jsp)
{
if (Cp->Value->IsTypeNum()) {
strcpy(g->Message, "Cannot make Json for a numeric column");
if (!Cp->Warned) {
PushWarning(g, Tp);
Cp->Warned = true;
} // endif Warned
Cp->Value->Reset();
#if 0
} else if (Value->GetType() == TYPE_BIN) {
......@@ -1635,6 +1641,7 @@ BSONCOL::BSONCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i)
Xnod = -1;
Xpd = false;
Parsed = false;
Warned = false;
} // end of BSONCOL constructor
/***********************************************************************/
......@@ -1653,6 +1660,7 @@ BSONCOL::BSONCOL(BSONCOL* col1, PTDB tdbp) : DOSCOL(col1, tdbp)
Xnod = col1->Xnod;
Xpd = col1->Xpd;
Parsed = col1->Parsed;
Warned = col1->Warned;
} // end of BSONCOL copy constructor
/***********************************************************************/
......@@ -1986,8 +1994,10 @@ void BSONCOL::ReadColumn(PGLOBAL g)
if (!Tbp->SameRow || Xnod >= Tbp->SameRow)
Value->SetValue_pval(Cp->GetColumnValue(g, Tbp->Row, 0));
#if defined(DEVELOPMENT)
if (Xpd && Value->IsNull() && !((PBDEF)Tbp->To_Def)->Accept)
throw("Null expandable JSON value");
htrc("Null expandable JSON value for column %s\n", Name);
#endif // DEVELOPMENT
// Set null when applicable
if (!Nullable)
......@@ -2274,8 +2284,10 @@ int TDBBSON::MakeDocument(PGLOBAL g)
Docp = Bp->NewVal(TYPE_JAR);
Bp->AddArrayValue(Docp, jsp);
Bp->SetArrayValue(arp, Docp, i);
} else
} else {
Top = Docp = Bp->NewVal(TYPE_JAR);
Bp->AddArrayValue(Docp, jsp);
} // endif's
} // endif jsp
......
......@@ -265,6 +265,7 @@ class DllExport BSONCOL : public DOSCOL {
char Sep; // The Jpath separator
bool Xpd; // True for expandable column
bool Parsed; // True when parsed
bool Warned; // True when warning issued
}; // end of class BSONCOL
/* -------------------------- TDBBSON class -------------------------- */
......
......@@ -1255,6 +1255,7 @@ JSONCOL::JSONCOL(PGLOBAL g, PCOLDEF cdp, PTDB tdbp, PCOL cprec, int i)
Xnod = -1;
Xpd = false;
Parsed = false;
Warned = false;
} // end of JSONCOL constructor
/***********************************************************************/
......@@ -1273,6 +1274,7 @@ JSONCOL::JSONCOL(JSONCOL *col1, PTDB tdbp) : DOSCOL(col1, tdbp)
Xnod = col1->Xnod;
Xpd = col1->Xpd;
Parsed = col1->Parsed;
Warned = col1->Warned;
} // end of JSONCOL copy constructor
/***********************************************************************/
......@@ -1606,6 +1608,12 @@ PVAL JSONCOL::MakeJson(PGLOBAL g, PJSON jsp)
{
if (Value->IsTypeNum()) {
strcpy(g->Message, "Cannot make Json for a numeric column");
if (!Warned) {
PushWarning(g, Tjp);
Warned = true;
} // endif Warned
Value->Reset();
#if 0
} else if (Value->GetType() == TYPE_BIN) {
......@@ -1703,8 +1711,8 @@ void JSONCOL::ReadColumn(PGLOBAL g)
if (!Tjp->SameRow || Xnod >= Tjp->SameRow)
Value->SetValue_pval(GetColumnValue(g, Tjp->Row, 0));
if (Xpd && Value->IsNull() && !((PJDEF)Tjp->To_Def)->Accept)
throw("Null expandable JSON value");
// if (Xpd && Value->IsNull() && !((PJDEF)Tjp->To_Def)->Accept)
// throw("Null expandable JSON value");
// Set null when applicable
if (!Nullable)
......
......@@ -192,7 +192,8 @@ class DllExport TDBJSN : public TDBDOS {
char Sep; // The Jpath separator
bool Strict; // Strict syntax checking
bool Comma; // Row has final comma
}; // end of class TDBJSN
bool Xpdable; // False: expandable columns are NULL
}; // end of class TDBJSN
/* -------------------------- JSONCOL class -------------------------- */
......@@ -247,7 +248,8 @@ class DllExport JSONCOL : public DOSCOL {
char Sep; // The Jpath separator
bool Xpd; // True for expandable column
bool Parsed; // True when parsed
}; // end of class JSONCOL
bool Warned; // True when warning issued
}; // end of class JSONCOL
/* -------------------------- TDBJSON class -------------------------- */
......
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