Thursday, April 18, 2013

Spaces in column names

I'm trying to use cakephp (2.3.2) to access an ms sqlserver db. I'm doing this via freetds on a linux platform ( after some unfinished hacking of the Mssql.php code from 1.3. )

I've just hit a problem in that many of the column and tables names that are used have spaces in them. After chasing my tail for some time I found it is due to the following code in lib/Cake/Model/Datasource/DboSource.php, [ which is still in the latest and greatest 2.4 version) that is  around 817:


        $data = trim($data);
        if (preg_match('/^[\w-]+(?:\.[^ \*]*)*$/', $data)) { // string, string.string
            if (strpos($data, '.') === false) { // string


The problem is regexp seems to exclude the possibility of spaces.  Ok - it's easy to fix   - maybe subclass the routine into Mssql to be good , but I have a  concern  that space is being deliberately excluded and bad things might happen if it was permitted. Has anyone got comments?

[ The spaces are not my choice  and out of my control , so answers like "alter the column and table names" are not appropriate.]



--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
 
---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

No comments: