chriskite / phactory

A Database Factory for PHP Unit Tests
http://phactory.org
MIT License
140 stars 39 forks source link

Fix for quoting table names. Pg fully qualified ids fix. #31

Open senz opened 10 years ago

senz commented 10 years ago

Quoting table name identifier db-specific. Handling of fully qualified identifiers.

jimbojsb commented 10 years ago

I'm not that familiar with the pgsql libraries. Is there a native quoting function that could be used?

senz commented 10 years ago

http://www.php.net/manual/ru/function.pg-escape-identifier.php Unfortunally it must use resource of connection

senz commented 10 years ago

Also PDO has this http://www.php.net/manual/en/pdo.quote.php But it is not suitable for identifiers, only literals. So no luck.

cank commented 10 years ago

postgres doesn't require quotes. Just using the quoteIdentifier (for postgres this is ") function already defined as part of the PgsqlUtil class should suffice.

senz commented 10 years ago

Quoted identifier is a special case http://www.postgresql.org/docs/9.1/static/sql-syntax-lexical.html. And it is handled different from unquoted (case sensitive, i.e.). Basic function does not support fully qualified identifiers, and unquoted identifier cannot start with digit (quoted can). I agree that pg-specific func must fully support lexical rules for pg, i will try to implement solution for this.

senz commented 10 years ago

So here is patch that returns original behavior but treats already quoted identifiers specially (passing thru). And some tests.