Thought: dates

13 views
Skip to first unread message

David Welton

unread,
Aug 4, 2014, 5:03:13 AM8/4/14
to epg...@googlegroups.com
Hi,

I'm struggling with an issue in Chicago Boss caused by the fact that
there is no way to tell erlang:date() apart from erlang:now():

https://github.com/ChicagoBoss/ChicagoBoss/issues/489

One thought would, indeed, be to hack epgsql to make it return a tuple
of tuples for dates, so that they're very clearly not now() values.

Of course this would be very backwards-incompatible...

Thoughts?
--
David N. Welton

http://www.welton.it/davidw/

http://www.dedasys.com/

Michael Truog

unread,
Aug 4, 2014, 12:26:41 PM8/4/14
to David Welton, epg...@googlegroups.com
On 08/04/2014 02:03 AM, David Welton wrote:
> Hi,
>
> I'm struggling with an issue in Chicago Boss caused by the fact that
> there is no way to tell erlang:date() apart from erlang:now():
>
> https://github.com/ChicagoBoss/ChicagoBoss/issues/489
>
> One thought would, indeed, be to hack epgsql to make it return a tuple
> of tuples for dates, so that they're very clearly not now() values.
>
> Of course this would be very backwards-incompatible...
>
> Thoughts?
Hi David,

I think it is important that epgsql does not do conversions by default for compatibility, but also because that approach can be desirable in certain situations. If epgsql does convert types, it would be best to do so based on some configuration flag, so the conversions don't happen automatically. If the conversions don't occur it may be better for GC behavior, depending on the size of the binaries that are returned (greater than 64 bytes would make this matter, http://www.erlang.org/doc/efficiency_guide/binaryhandling.html#id65218).

Anyway, you shouldn't need to be concerned about epgsql supporting the conversion when using Chicago Boss, since boss_db is suppose to be doing the conversion for you. It has been awhile since I have used boss_db and there have been various changes to it, since I used it last, but you should be able to use a timestamp value to handle dates. I understand there is a problem when you care about dates previous to 1970, which might be part of the issue. You can always handle the date conversion yourself or modify boss_db to improve this though.

Regards,
Michael

David Welton

unread,
Aug 5, 2014, 5:08:22 AM8/5/14
to Michael Truog, epg...@googlegroups.com
> I think it is important that epgsql does not do conversions by default for
> compatibility, but also because that approach can be desirable in certain
> situations. If epgsql does convert types, it would be best to do so based
> on some configuration flag, so the conversions don't happen automatically.
> If the conversions don't occur it may be better for GC behavior, depending
> on the size of the binaries that are returned (greater than 64 bytes would
> make this matter,
> http://www.erlang.org/doc/efficiency_guide/binaryhandling.html#id65218).

Well all types are converted to *something* from the binary format
they arrive in, if you're doing an 'equery', rather than an 'squery'.
The trick is deciding what to convert to.

Ultimately, this is an Erlang problem, because Erlang attaches no
information to erlang:now() and erlang:date() that allows you to
distinguish one from the other. This is a problem if you don't know
exactly what generated your data, which is of course the case in more
loosely coupled systems.

> Anyway, you shouldn't need to be concerned about epgsql supporting the
> conversion when using Chicago Boss, since boss_db is suppose to be doing the
> conversion for you. It has been awhile since I have used boss_db and there
> have been various changes to it, since I used it last, but you should be
> able to use a timestamp value to handle dates. I understand there is a
> problem when you care about dates previous to 1970, which might be part of
> the issue. You can always handle the date conversion yourself or modify
> boss_db to improve this though.

Yeah, it's probably best to put it in boss_db. We're changing enough
things as it is.
Reply all
Reply to author
Forward
0 new messages