Ticket #1592 (closed defect: fixed)
Oracle DataDict NUMBER and VARCHAR2 issues
| Reported by: | adrive | Owned by: | jwage |
|---|---|---|---|
| Priority: | major | Milestone: | 1.2.0 |
| Component: | Schema Files | Version: | 1.0.3 |
| Severity: | abc | Keywords: | |
| Cc: | Has Test: | no | |
| Status: | Commit Approved | Has Patch: | no |
Description (last modified by jwage) (diff)
Hello. I decide to create this ticket, because I am not sure, if the way I decide to solve some issues is right and I would like to discuss about it.
VARCHAR2 issues:
Oracle supports VARCHAR2 columns to be 4000 bytes long. So we can store 4000 CHARS in VARCHAR2 columns, but not unicode. So I decide to make a patch to allow store max. 2000 CHARS in VARCHAR2 columns to be able to store also unicode chars without getting an 4000 bytes exceed error.
Maybe the other solution woul be to specify unit parameter of column with two possible values: chars, bytes. And the user should make decission which one will be used. I can create a patch also for this possibility. But now, VARCHAR2 length is unlimited, which trigger errors when creating tables in database.
NUMBER issues:
Now when descibing number columns in MySQL or Posgresql should be specified:
bigint: type: integer(8) integer: type: integer(4) mediumint: type: integer(3) smallint: type: integer(2) tinyint: type: integer(1) ...
In MySQL or Pgsql this will generate integer(4) => INTEGER, integer(3) => MEDIUMINT, integer(2) => SMALLINT, integer(1) => TINYINT. As lenght means number of bytes the number will be stored in. Oracle doesn't support any of the *INT, even there are some synonyms for NUMBER (INTEGER, SMALLINT).
In oracle NUMBER datatype should have two params precisions and scale.
In Oracle integer(4) will be NUMBER(4) which means, that the biggest possible value for this column is 9999. As there are alredy some plugins (sfDoctrineGuard) that uses for id definition the lenght for integer(4) it means, that in Oracle you cannot have more then 9999 sfGuardUsers in your database.
Therefor I am suggesting to translating the size attribute of number columns to equivalents of BIGINT, MEDIUMINT... For example:
integer(1) to NUMBER(3) // max value 255 in unisgned TINYINT in MySQL integer(2) to NUMBER(5) // max value 65535 in unsigned SMALLINT integer(3) to NUMBER(8) // MEDIUMINT 16777215 integer(4) to NUMBER(10) // INT 2147483647 integer(8) to NUMBER(20) // BIGINT 18446744073709551615
Any size of integer definition larger than 8 and smaller than 38 will be translated tu NUMBER(n)
Of course, in datadict should be new type - number, and anyone who will use only Oracle should be able to define NUMBER(precision, scale) as he wants.
I will provide Oracle for Doctrine developers in a few days. But you will need Oracle client and compiled oci8 drivers.
