Menu ▾ ▴

#66 TdzDbColumnDescription.GetDefaultString: a default value that is not a valid date or integer gives '*NULL*' or raises

unread
nobody
2026-10-14
2026-10-14
No

TdzDbColumnDescription.GetDefaultString in dbcreator/u_dzDbCreatorDescription.pas passes the default value to FormatData, which converts it with Var2DateTimeStr (dtDate), Var2IntStr (dtLongInt), Var2DblStr (dtDouble) or Var2Str.

The default value is always a string, though: the default attribute read by u_dzDbCreatorReadXml, or the ADOX Default property read by u_dzDbCreatorReadAccessDb, which for Access can be an expression such as Now() or Date().

  • Up to r2434 (dtLongInt) and r2437 (dtDate), a string that did not convert gave '*NULL*', and GetDefaultString still returned True. The writers used that as the real default: DEFAULT '*NULL*' in the MS SQL and Oracle DDL, default="*NULL*" in the XML (so an XML round trip replaced the original default), *NULL* in the HTML.
  • Since [bugs:#63] (r2435, dtLongInt) and [features:#30] (r2438, dtDate) the same input raises EVariantConvertError. dtDouble always raised.
  • A date string that does convert goes through VarDateFromStr and therefore depends on the locale of the machine.

The default is text in the syntax of the source database, not data. GetDefaultString should pass a string default through unchanged instead of converting it. FormatData for field values (varDate or Null from ADO) is not affected.

Reported by the dzlib-sync session, found by reading the code.

Related

Bug Reports: #63
Feature Requests: #30
Feature Requests: #34

Discussion


Log in to post a comment.