Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Proposal to add quoteDateTime to JDatabaseDriver class
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Will Daniels  
View profile  
 More options Apr 12 2012, 9:06 pm
From: Will Daniels <m...@willdaniels.co.uk>
Date: Fri, 13 Apr 2012 02:06:52 +0100
Local: Thurs, Apr 12 2012 9:06 pm
Subject: Proposal to add quoteDateTime to JDatabaseDriver class
Hi,

[I mentioned this a couple of weeks back on the general list and was asked to
raise it here for platform]

Would anybody oppose the addition of a quoteDateTime method to the database
driver class?

The issue is that not all RDBMS use string literals for date/time values. The
way things are done currently using getDateFormat (and JDate::toSql accordingly)
does not quote the result as a string literal, which means everything that calls
it will blindly quote the result afterwards. So this makes it impossible to use
any other escape notation. For example, ODBC likes timestamp values supplied
using the "brace escape" syntax:

   { ts 'YYYY-MM-DD hh:mm:ss' }
   { d 'YYYY-MM-DD' }
   { t 'hh:mm:ss' }

The SQL standard specifies a type prefix TIMESTAMP, DATE or TIME, e.g.

   TIMESTAMP 'YYYY-MM-DD hh:mm:ss'

Microsoft Access (!?) would want:

   #YYYY-MM-DD hh:mm:ss#

There may be other/better examples, but I think ODBC is the main one and is
where I came up against this issue.

Currently, if I were to override getDateTime to:

   return '{ \\t\\s \'d.m.Y H:i:s\' }';

...the correct syntax is produced by PHP in DateTime::format, but everywhere in
Joomla! this just gets escaped and quoted as a string literal, and so it ends up
in queries as something like:

   AND (foo OR a.publish_up <= '{ts \'24-03-2012 05:43:47\'}')

...instead of the required...

   AND (foo OR a.publish_up <= {ts '24-03-2012 05:43:47'})

My only solution to this at present has been to resort to rewriting queries
using regex in the driver class, which is obviously far from ideal.

While I understand that all _mainstream_ RDBMS are quite happy to take a string
literal for timestamp values, it makes enough sense (to me) to add a
quoteDateTime in line with quoteName and quote, since this is more convenient
for consumers anyway to have the literal string-quoted ready for them wherever
it does need to be quoted.

My proposal is to add this new method alongside getDateFormat and getNullDate to
avoid breakage and to patch the Platform and CMS at least to use the new method
(passing PHP null into quoteDateTime instead of using getNullDate). However, I'm
unsure about the possibility of deprecating the existing methods because there
may yet be some use for an unquoted format in DDL statements, since those tend
to use a string literal format for specifying DATETIME column DEFAULT values,
because DDL is processed differently by the ODBC drivers than SQL.

Any thoughts? Objections? If I prepare a commit for this, would it likely be
accepted? And if so, what do I put in the @since tag, "TBD" or just the next
version serial?

Thanks,
-Will


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrew Eddie  
View profile  
 More options Apr 13 2012, 2:05 am
From: Andrew Eddie <mambob...@gmail.com>
Date: Fri, 13 Apr 2012 16:05:45 +1000
Local: Fri, Apr 13 2012 2:05 am
Subject: Re: [jplatform] Proposal to add quoteDateTime to JDatabaseDriver class
I think a "quoteDate" method and a "qd" alias would be fine.

Regards,
Andrew Eddie
http://learn.theartofjoomla.com - training videos for Joomla developers

On 13 April 2012 11:06, Will Daniels <m...@willdaniels.co.uk> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rob Schley  
View profile  
 More options Apr 14 2012, 2:32 am
From: Rob Schley <eclectic...@gmail.com>
Date: Fri, 13 Apr 2012 23:32:56 -0700
Local: Sat, Apr 14 2012 2:32 am
Subject: Re: [jplatform] Proposal to add quoteDateTime to JDatabaseDriver class

I was not aware of this problem but it seems like a reasonable solution. If
you're going to do a pull request, it would sure be nice if you fixed up
the existing quoted dates to use the new method. As far as the version
number, I would suggest you put 12.2 as that is the more likely version for
it to be merged into.

Cheers,
Rob


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
84.le0n  
View profile  
 More options Apr 14 2012, 6:59 am
From: "84.le0n" <84.l...@gmail.com>
Date: Sat, 14 Apr 2012 12:59:41 +0200
Local: Sat, Apr 14 2012 6:59 am
Subject: Re: [jplatform] Proposal to add quoteDateTime to JDatabaseDriver class
Let me know which pull request will be, to help you about PostgreSQL date quote.

Eng. Gabriele Pongelli.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions Older topic »