[GB.DB.POSTGRESQL]
* BUG: Gambas date/time values without date is now stored as the minimum possible date that PostgreSQL accepts, '4713-01-01 BC'. git-svn-id: svn://localhost/gambas/trunk@7506 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
fca1fb8e0e
commit
18ac7691c3
1 changed files with 10 additions and 1 deletions
|
@ -456,6 +456,11 @@ static void conv_data(const char *data, int len, GB_VARIANT_VALUE *val, Oid type
|
|||
if (bc)
|
||||
date.year = (-date.year);
|
||||
|
||||
// 4713-01-01 BC is used for null dates
|
||||
|
||||
if (date.year == -4713 && date.month == 1 && date.day == 1)
|
||||
date.year = date.month = date.day = 0;
|
||||
|
||||
GB.MakeDate(&date, (GB_DATE *)&conv);
|
||||
|
||||
val->type = GB_T_DATE;
|
||||
|
@ -867,9 +872,13 @@ static int format_value(GB_VALUE *arg, DB_FORMAT_CALLBACK add)
|
|||
|
||||
date = GB.SplitDate((GB_DATE *)arg);
|
||||
|
||||
// Gambas year is between -4801 and +9999
|
||||
// PostgreSQL year is between -4713 and +294276
|
||||
// So let's use -4713 for representing null dates.
|
||||
|
||||
if (date->year == 0)
|
||||
{
|
||||
l = sprintf(_buffer, "'%02d:%02d:%02d'", date->hour, date->min, date->sec);
|
||||
l = sprintf(_buffer, "'4713-01-01 %02d:%02d:%02d BC'", date->hour, date->min, date->sec);
|
||||
add(_buffer, l);
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Reference in a new issue