In PostgreSQL you've to quote an identifier if you want to handle it
in a case sensitive manner, otherwise it will be handled as lowercase.
In case you create a table with quote (so it's case sensitive) that
contains at least an uppercase character and then call this table
without quote, PostgreSQL will return an error of table not found.
Your proposal is really useful ;)
It can be done with explode and implode, adding quote char before and
after passed string.
I'll work to add this feature on my driver.
End. Gabriele Pongelli
Eng. Gabriele Pongelli.
https://github.com/joomla/joomla-platform/pull/658
Regards,
Andrew Eddie
http://learn.theartofjoomla.com - training videos for Joomla 1.7 developers
$db->quoteName('a.foo')
will return `a`.`foo` (quotes adjusted for the db engine, of course).
There is probably a nice mop up job to do over the code base if people
are bored with their Christmas presents :)
Regards,
Andrew Eddie
http://learn.theartofjoomla.com - training videos for Joomla 1.7 developers
These are my tests for your version of quoteName:
1) quoteName('column') will return "column" (in PostgreSQL, this is
with backtick in MySQL) --> that's CORRECT
2) quoteName('table.column') will return "table"."column" --> that's CORRECT
3) quoteName( array('table', 'column') ) will return "table"."column"
--> that's WRONG for me, same result as 2) , I think it's better that
returns an array ( 0 => "table", 1 => "column" ) as separate name
4) quoteName( array('table.col1', 'col2') ) will return
"table.col1"."col2" --> that's WRONG for me, first argument is not
quoted correctly, I think it's better that returns an array (
"table1"."col" , "col2 ), so it behave like 3) plus dot complexity.
When I've tried to quoteName with array I thought that array variable
were used to quote a list of name and not to concatenate them as they
were separated by a dot.
Have you designed this change to behave like this or it's a side effect ?
I think it's better improve that behaviour, don't you ?
Thank you,
Eng Gabriele Pongelli.
2011/12/22 Andrew Eddie <mamb...@gmail.com>:
Yes, that's a reasonable change. I'm happy for quoteName to take an
array of names to quote rather than an array of the parts of a single
name. Go ahead and make a pull request for that.
I've also been wondering whether quoteName should take an alias
argument, for example:
quoteName('a.foo', 'bar') could return " `a`.`foo` AS `bar` "
Regards,
Andrew Eddie
http://learn.theartofjoomla.com - training videos for Joomla 1.7 developers
$query->from($query->qn('foo', 'a')
should translate to:
" FROM `foo` AS a "
Regards,
Andrew Eddie
http://learn.theartofjoomla.com - training videos for Joomla 1.7 developers
$query->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
becomes
$query->join('LEFT', '#__users', 'uc', 'uc.id=a.checked_out');
or
$query->join('LEFT', '#__users', 'uc', $db->qn('uc.id') . '=' .
$db->qn('a.checked_out'));
Just seems like the more we can parse the query pieces, the easier it
is for the db methods to process the pieces as needed. But maybe it is
too complicated and not needed.
Mark
Regards,
Andrew Eddie
http://learn.theartofjoomla.com - training videos for Joomla 1.7 developers
it works with strings and arrays, with and without dot notation.
For "AS" changes I'll do it.
ps
Merry Christmas for those who believes.
Happy Holiday ;-)
Bye!