Project

General

Profile

Actions

Bug #20470

closed

Column's default value is not properly quoted in CREATE TABLE

Added by Xavier Perseguers almost 15 years ago. Updated over 14 years ago.

Status:
Closed
Priority:
Should have
Category:
Database API (Doctrine DBAL)
Target version:
-
Start date:
2009-05-19
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

When creating a table a few steps are involved to parse the MySQL table creation definition and rewrite it to be compatible with another DBMS.

First step after parsing gives back an array [parsed_columns.png].

The value ['DEFAULT']['value']0 may contain a numeric value. The method compileFieldCfg() returns a definition as

I8 default '0' NOQUOTE

meaning this should be created as a integer with default value '0' (the single quote comes from ['DEFAULT']['value']1)

and it should be unquoted later on.

When having a string, if the default value is empty, then following definition is returned for instance:

C 255 default "''" NOQUOTE

You have to read it {double-quote}{single-quote}{single-quote}{double-quote}

The default value will get unquoted which result in '' (2x single quote) which is OK.

However when there is a default value which is non-numeric the following definition is returned:

C 255 default 'wwwhomepage' NOQUOTE

which is then unquoted and the actual code sent to the database is something like that:

CREATE TABLE "tx_euldap_server" (
...
"www" VARCHAR DEFAULT wwwhomepage,
...
)

which does not work as anybody may understand. For instance the SQL part of what is shown on [parsed_columns.png] is

CREATE TABLE "tx_euldap_server" (
...
"country" VARCHAR DEFAULT countrycode,
"www" VARCHAR DEFAULT wwwhomepage,
"user" VARCHAR DEFAULT '',
...
)

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:

CREATE TABLE "tx_euldap_server" (
...
"country" VARCHAR DEFAULT 'countrycode',
"www" VARCHAR DEFAULT 'wwwhomepage',
"user" VARCHAR DEFAULT '',
...
)

(issue imported from #M11142)


Files

parsed_columns.png (8.4 KB) parsed_columns.png Administrator Admin, 2009-05-19 09:51
11142.diff (1.01 KB) 11142.diff Administrator Admin, 2009-05-19 09:53
11142_v2.diff (932 Bytes) 11142_v2.diff Administrator Admin, 2009-11-02 11:29
11142_v3.diff (2.41 KB) 11142_v3.diff Administrator Admin, 2009-11-20 11:59

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #17019: SQL error with DBAL/PostgreSQL: quoting of varchar defaultsClosedKarsten Dambekalns2007-02-20

Actions
Actions #1

Updated by Xavier Perseguers over 14 years ago

Could not reproduce for a while, lowering its severity.

Actions #2

Updated by Xavier Perseguers over 14 years ago

Added v2 against current trunk if this patch should ever be used (still pending)

Actions #3

Updated by Xavier Perseguers over 14 years ago

I could confirm this behavior while writing unit tests for #12670

Actions #4

Updated by Xavier Perseguers over 14 years ago

Committed to DBAL-trunk as revision 26752.
Backported to branch DBAL_1-0 as revision 26754.

Actions #5

Updated by Xavier Perseguers over 14 years ago

Closed after testing (again) that EXT:eu_ldap could be installed properly

Actions

Also available in: Atom PDF