cakephp / cakephp/phinx

Handle case specificities

Open
#2,345 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
4.5k
Forks
884
PR merge metrics
No merged PRs in 30d

Description

Context : I'm trying to write an OciAdapter to handle migrations inside an Oracle database

Expected behaviour :

  • the migration table is created automatically with no change, or a simple overriding
  • after having created a migration, getVersionLog returns this migration
  • after having run this migration, getVersionLog returns that this migration has been executed

Actual behaviour :

  • the migration table is created
  • getVersionLog always return an array with empty objects.

For certain SGBDs (Oracle, not to mention it), the case of the SELECTed field name can be different than the one returned.

CREATE TABLE (version ...) will lead to a column named VERSION.
and in that case, SELECT version FROM ... will lead, when fetched, to an array whose key is "VERSION"

Note that quoting the column will preserve the case. But quoting columns require to always write it the same manner.
If you query your table quoting the columns - i.e., SELECT "version" FROM ... -, then Oracle will give you an "Unknown column" error if you create the table with a "CREATE TABLE (version...) " that creates a column named VERSION.

This issue is here to find a solution that :

  • is DB-Agnostic
  • avoid rewriting an entire method (getVersionLog, for instance) just to change ['version'] into ['VERSION']
  • keep the code logical (if I write "SELECT version", I expect to be able to do a $result['version'])

PS : Moreover, in the present case (getVersionLog), we have a "select *", so fields are not even explicitely mentioned

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue identifies getVersionLog and the migration-table query as the entry points; no file or test path is provided. Start by tracing how SELECT results are mapped for Oracle and other databases. Done means version rows use the expected logical field names without rewriting getVersionLog or breaking quoted and unquoted identifiers.

Written by the indexing model from the issue text.

Assessment

Tech stack
php, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.