2 namespace TYPO3\CMS\Dbal\Tests\Unit\Database;
34 $configuration = array(
35 'handlerCfg' => array(
39 'driver' =>
'postgres',
44 'tx_templavoila_tmplobj' => array(
45 'mapFieldNames' => array(
46 'datastructure' =>
'ds',
50 'mapFieldNames' => array(
58 $this->subject = $this->prepareSubject(
'postgres7', $configuration);
66 $this->assertTrue($this->subject->runningADOdbDriver(
'postgres'));
75 $result = $this->subject->SELECTquery(
'*',
'be_users',
'1=1',
'',
'',
'20');
76 $expected =
'SELECT * FROM "be_users" WHERE 1 = 1 LIMIT 20';
77 $this->assertEquals($expected, $this->
cleanSql($result));
86 $result = $this->subject->SELECTquery(
'*',
'be_users',
'1=1',
'',
'',
'20,40');
87 $expected =
'SELECT * FROM "be_users" WHERE 1 = 1 LIMIT 40 OFFSET 20';
88 $this->assertEquals($expected, $this->
cleanSql($result));
97 $result = $this->subject->SELECTquery(
'*',
'fe_users',
'FIND_IN_SET(10, usergroup)');
98 $expected =
'SELECT * FROM "fe_users" WHERE FIND_IN_SET(10, CAST("usergroup" AS CHAR)) != 0';
99 $this->assertEquals($expected, $this->
cleanSql($result));
108 $result = $this->subject->SELECTquery(
'pages.uid',
'pages',
'FIND_IN_SET(10, pages.fe_group)');
109 $expected =
'SELECT "pages"."uid" FROM "pages" WHERE FIND_IN_SET(10, CAST("pages"."fe_group" AS CHAR)) != 0';
110 $this->assertEquals($expected, $this->
cleanSql($result));
119 $result = $this->subject->SELECTquery(
'*',
'tt_content',
'bodytext LIKE BINARY \'test\'');
120 $expected =
'SELECT * FROM "tt_content" WHERE "bodytext" LIKE \'test\'';
121 $this->assertEquals($expected, $this->
cleanSql($result));
130 $result = $this->subject->SELECTquery(
'*',
'tt_content',
'bodytext NOT LIKE BINARY \'test\'');
131 $expected =
'SELECT * FROM "tt_content" WHERE "bodytext" NOT LIKE \'test\'';
132 $this->assertEquals($expected, $this->
cleanSql($result));
141 $result = $this->subject->SELECTquery(
'*',
'tt_content',
'bodytext LIKE \'test\'');
142 $expected =
'SELECT * FROM "tt_content" WHERE "bodytext" ILIKE \'test\'';
143 $this->assertEquals($expected, $this->
cleanSql($result));
152 $result = $this->subject->SELECTquery(
'*',
'tt_content',
'bodytext NOT LIKE \'test\'');
153 $expected =
'SELECT * FROM "tt_content" WHERE "bodytext" NOT ILIKE \'test\'';
154 $this->assertEquals($expected, $this->
cleanSql($result));
163 $result = $this->subject->SELECTquery(
'*',
'pages',
'pid<>3');
164 $expected =
'SELECT * FROM "pages" WHERE "pid" <> 3';
165 $this->assertEquals($expected, $this->
cleanSql($result));
174 $parseString =
'ALTER TABLE sys_collection ADD KEY parent (pid,deleted)';
175 $components = $this->subject->SQLparser->_callRef(
'parseALTERTABLE', $parseString);
176 $this->assertInternalType(
'array', $components);
178 $result = $this->subject->SQLparser->compileSQL($components);
179 $expected = array(
'CREATE INDEX "dd81ee97_parent" ON "sys_collection" ("pid", "deleted")');
180 $this->assertSame($expected, $this->
cleanSql($result));
189 $parseString =
'ALTER TABLE sys_file ADD uid INT(11) NOT NULL AUTO_INCREMENT';
190 $components = $this->subject->SQLparser->_callRef(
'parseALTERTABLE', $parseString);
191 $this->assertInternalType(
'array', $components);
193 $result = $this->subject->SQLparser->compileSQL($components);
194 $expected = array(
'ALTER TABLE "sys_file" ADD COLUMN "uid" SERIAL');
195 $this->assertSame($expected, $this->
cleanSql($result));
204 $parseString =
'ALTER TABLE sys_collection DROP KEY parent';
205 $components = $this->subject->SQLparser->_callRef(
'parseALTERTABLE', $parseString);
206 $this->assertInternalType(
'array', $components);
208 $result = $this->subject->SQLparser->compileSQL($components);
209 $expected = array(
'DROP INDEX "dd81ee97_parent"');
210 $this->assertSame($expected, $this->
cleanSql($result));
219 $result = $this->subject->SELECTquery(
'COUNT(title)',
'pages',
'',
'title',
'title');
220 $expected =
'SELECT COUNT("title") FROM "pages" GROUP BY "title" ORDER BY "title"';
221 $this->assertEquals($expected, $this->
cleanSql($result));
230 $result = $this->subject->SELECTquery(
'COUNT(title), COUNT(pid)',
'pages',
'',
'title, pid',
'title, pid');
231 $expected =
'SELECT COUNT("title"), COUNT("pid") FROM "pages" GROUP BY "title", "pid" ORDER BY "title", "pid"';
232 $this->assertEquals($expected, $this->
cleanSql($result));
241 $result = $this->subject->SELECTquery(
'COUNT(title)',
'pages',
'',
'',
'title');
242 $expected =
'SELECT COUNT("title") FROM "pages"';
243 $this->assertEquals($expected, $this->
cleanSql($result));
252 $result = $this->subject->SELECTquery(
'COUNT(title), COUNT(pid)',
'pages',
'',
'',
'title, pid');
253 $expected =
'SELECT COUNT("title"), COUNT("pid") FROM "pages"';
254 $this->assertEquals($expected, $this->
cleanSql($result));
263 $result = $this->subject->SELECTquery(
'COUNT(title), COUNT(pid)',
'pages',
'',
'title',
'title, pid');
264 $expected =
'SELECT COUNT("title"), COUNT("pid") FROM "pages" GROUP BY "title" ORDER BY "title"';
265 $this->assertEquals($expected, $this->
cleanSql($result));
277 $actual= $this->subject->getEquivalentFieldDefinition($fieldSQL);
278 $this->assertSame($expected, $actual);
287 array(
'int(11) NOT NULL default \'0\'',
'int(11) NOT NULL default \'0\''),
288 array(
'int(10) NOT NULL',
'int(11) NOT NULL'),
289 array(
'tinyint(3)',
'smallint(6)'),
290 array(
'bigint(20) NOT NULL',
'bigint(20) NOT NULL'),
291 array(
'tinytext NOT NULL',
'varchar(255) NOT NULL default \'\''),
292 array(
'tinytext',
'varchar(255) default NULL'),
293 array(
'mediumtext',
'longtext')