[TYPO3-core] RFC #11142: DBAL: Column's default value is not properly quoted in CREATE TABLE
Xavier Perseguers
typo3 at perseguers.ch
Sun Jun 21 10:19:57 CEST 2009
v3 attached (v2 did was not created against root)
Sorry!
Xavier Perseguers wrote:
> Hi Masi,
>
>>>> Solution:
>>>> ------------------------------------
>>>> It is clear that the only valid definition is the last one with an
>>>> empty
>>>> default value. My patch removes the NOQUOTE attribute when default
>>>> value
>>>> is not numeric and it results to a valid SQL:
>>>
>>> Why don't you init like this:
>>> $noQuote = false;
>
> The test for changing the value of $noQuote is made inside a condition
> (the "if" after the initialization of $noQuote), while its use for
> appending or not the "NOQUOTE" text is made after that. I have to set it
> to TRUE at the beginning to be backward-compatible and not change the
> behaviour of the code.
>
>>> So I think the quoting should be based on the field type. No quotes for
>>> I,I1,I2,I3,I4,I8,F and N, possibly for L as well.
>>
>> Here is the full list of available types (from code):
>>
>> switch($meta) {
>> case 'C': return 'VARCHAR';
>> case 'X': return $this->typeX;
>> case 'XL': return $this->typeXL;
>>
>> case 'C2': return 'NVARCHAR2';
>> case 'X2': return 'NVARCHAR2(4000)';
>>
>> case 'B': return 'BLOB';
>>
>> case 'D':
>> case 'T': return 'DATE';
>> case 'L': return 'NUMBER(1)';
>> case 'I1': return 'NUMBER(3)';
>> case 'I2': return 'NUMBER(5)';
>> case 'I':
>> case 'I4': return 'NUMBER(10)';
>>
>> case 'I8': return 'NUMBER(20)';
>> case 'F': return 'NUMBER';
>> case 'N': return 'NUMBER';
>> case 'R': return 'NUMBER(20)';
>> default:
>> return $meta;
>> }
>>
>> Thus, you're right, best would be to test the field type and remove
>> quotes for I, I1, I2, I4 (I3 does not exist), I8, F, N, L and R.
>>
>> I make another patch for this (including noQuote stuff).
>
> Patch updated with 11142_v2.diff
>
>>> And I fear due to the unfortunate structure of the classes also
>>> class.ux_t3lib_sqlparser.php has to be patched.
>>
>> Well, no, it's not required but I would really like someone to
>> re-synchronize both files as a few patches were applied to its friend
>> class.ux_t3lib_sql*parser*.php.
>
> Patch updated and added synchronization with
> class.ux_t3lib_sqlparser.php in 11142_v2-with-sqlparser.diff
>
> Regards
>
--
Xavier Perseguers
http://xavier.perseguers.ch/en
One contribution a day keeps the fork away
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 11142_v3-with-sqlparser.diff
Url: http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20090621/97353fa7/attachment-0002.txt
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: 11142_v3.diff
Url: http://lists.netfielders.de/pipermail/typo3-team-core/attachments/20090621/97353fa7/attachment-0003.txt
More information about the TYPO3-team-core
mailing list