You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xsp-dev@xml.apache.org by Matt Sergeant <ma...@sergeant.org> on 2001/01/24 16:38:58 UTC

Another ESQLism

get-<type> is annoying for dynamic languages. I'm going to add get-column
to AxKit's ESQL implementation, I suggest that Cocoon should see if it can
do similar, unless someone has strenuous objections with good reasons.

-- 
<Matt/>

    /||    ** Director and CTO **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // **     Personal Web Site: http://sergeant.org/     **
     \\//
     //\\
    //  \\


Re: Another ESQLism

Posted by Matt Sergeant <ma...@sergeant.org>.
On Wed, 24 Jan 2001, Donald Ball wrote:

> On Wed, 24 Jan 2001, Matt Sergeant wrote:
>
> > I wish DBI would return Time::Objects. :-)
>
> you could enforce this sort of policy by having esql:get-date, get-time,
> and get-timestamp automatically parse the date/time string and return a
> Time::Object to the user...?

You have to do different parsing depending on which database you're
running, and what the locale settings of the DB are. In short, its a
nightmare. We're doing that on a current project here, but luckily we have
a database abstraction layer (something thats not currently possible with
XSP, but *shrug*) that handles most of those issues.

I did think about checking the database type, and figuring it out, but it
gets real hard. This is one area DBI is sadly lacking (I'll probably poke
Tim Bunce about it at the perl conference this year).

-- 
<Matt/>

    /||    ** Director and CTO **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // **     Personal Web Site: http://sergeant.org/     **
     \\//
     //\\
    //  \\


Re: Another ESQLism

Posted by Donald Ball <ba...@webslingerZ.com>.
On Wed, 24 Jan 2001, Matt Sergeant wrote:

> I wish DBI would return Time::Objects. :-)

you could enforce this sort of policy by having esql:get-date, get-time,
and get-timestamp automatically parse the date/time string and return a
Time::Object to the user...?

- donald


Re: Another ESQLism

Posted by Matt Sergeant <ma...@sergeant.org>.
On Wed, 24 Jan 2001, Donald Ball wrote:

> On Wed, 24 Jan 2001, Matt Sergeant wrote:
>
> > What I mean by dynamic languages is just that Perl has no concept of
> > anything other than a scalar in terms of variables, so it makes no
> > difference. (whats annoying about this is that DBI returns date/time
> > columns as strings, not as objects, so you have no way to format them
> > except in SQL).
>
> right - and that's about the only time getting a special object from the
> resultset instead of a string is nice. date formatting in java rocks the
> party. although, to be fair, i recall a perl module which could take
> _insane_ date strings, like:
>
> "two minutes after midnight on the 3rd tuesday in march, in the year of
> our lord nineteen hundred and seventy-four"
>
> and parse it into a generic date object. absolutely amazing.

Date::Manip. And you can do stuff like: "today plus twenty working days"
too. But its bloated and nasty code. I prefer Time::Object (but then I
wrote it), which gives you the full run of date methods (like day, year,
min, hour, day_of_year, etc) along with operator overloaded date
differences, like:

use Time::Object;
use Time::Seconds;

my $today = localtime();
my $yesterday = $today - ONE_DAY;

print "Yesterday is: $yesterday\n";

my $diff = $today - $yesterday;
printf "Difference: hours: %d mins: %d secs: %d\n",
	$diff->hours, $diff->minutes, $diff->seconds;

Prints:

Yesterday is: Tue Jan 23 20:14:16 2001
Difference: hours: 24 mins: 1440 secs: 86400

I wish DBI would return Time::Objects. :-)

Of course Java decided that they needed to reinvent the wheel *yet again*
with Date formats (as they did with number formats) and invent their own
syntax, rather than using strftime (or talking to the ISO/ANSI about what
they thought were weaknesses in strftime). Time::Object obviously uses
strftime() to format dates, not Java DateFormat objects.

-- 
<Matt/>

    /||    ** Director and CTO **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // **     Personal Web Site: http://sergeant.org/     **
     \\//
     //\\
    //  \\


Re: Another ESQLism

Posted by Donald Ball <ba...@webslingerZ.com>.
On Wed, 24 Jan 2001, Matt Sergeant wrote:

> What I mean by dynamic languages is just that Perl has no concept of
> anything other than a scalar in terms of variables, so it makes no
> difference. (whats annoying about this is that DBI returns date/time
> columns as strings, not as objects, so you have no way to format them
> except in SQL).

right - and that's about the only time getting a special object from the
resultset instead of a string is nice. date formatting in java rocks the
party. although, to be fair, i recall a perl module which could take
_insane_ date strings, like:

"two minutes after midnight on the 3rd tuesday in march, in the year of
our lord nineteen hundred and seventy-four"

and parse it into a generic date object. absolutely amazing.

- donald


Re: Another ESQLism

Posted by Matt Sergeant <ma...@sergeant.org>.
On Wed, 24 Jan 2001, Donald Ball wrote:

> On Wed, 24 Jan 2001, Matt Sergeant wrote:
>
> > get-<type> is annoying for dynamic languages. I'm going to add get-column
> > to AxKit's ESQL implementation, I suggest that Cocoon should see if it can
> > do similar, unless someone has strenuous objections with good reasons.
>
> the get-<type> methods have nothing to do with java typing of the columns,
> and everything to do with sql typing of the columns. that being said, i
> think we can both support a get-column method - in java, it will just call
> getObject on the ResultSet. sounds good?

Yes sounds fine.

What I mean by dynamic languages is just that Perl has no concept of
anything other than a scalar in terms of variables, so it makes no
difference. (whats annoying about this is that DBI returns date/time
columns as strings, not as objects, so you have no way to format them
except in SQL).

-- 
<Matt/>

    /||    ** Director and CTO **
   //||    **  AxKit.com Ltd   **  ** XML Application Serving **
  // ||    ** http://axkit.org **  ** XSLT, XPathScript, XSP  **
 // \\| // **     Personal Web Site: http://sergeant.org/     **
     \\//
     //\\
    //  \\


Re: Another ESQLism

Posted by Donald Ball <ba...@webslingerZ.com>.
On Wed, 24 Jan 2001, Matt Sergeant wrote:

> get-<type> is annoying for dynamic languages. I'm going to add get-column
> to AxKit's ESQL implementation, I suggest that Cocoon should see if it can
> do similar, unless someone has strenuous objections with good reasons.

the get-<type> methods have nothing to do with java typing of the columns,
and everything to do with sql typing of the columns. that being said, i
think we can both support a get-column method - in java, it will just call
getObject on the ResultSet. sounds good?

- donald