TYPO3 CMS  TYPO3_6-2
DatabaseConnectionPostgresqlTest.php
Go to the documentation of this file.
1 <?php
3 
21 
25  protected $subject;
26 
32  public function setUp() {
33  $configuration = array(
34  'handlerCfg' => array(
35  '_DEFAULT' => array(
36  'type' => 'adodb',
37  'config' => array(
38  'driver' => 'postgres',
39  ),
40  ),
41  ),
42  'mapping' => array(
43  'tx_templavoila_tmplobj' => array(
44  'mapFieldNames' => array(
45  'datastructure' => 'ds',
46  ),
47  ),
48  'Members' => array(
49  'mapFieldNames' => array(
50  'pid' => '0',
51  'cruser_id' => '1',
52  'uid' => 'MemberID',
53  ),
54  ),
55  ),
56  );
57  $this->subject = $this->prepareSubject('postgres7', $configuration);
58  }
59 
64  $this->assertTrue($this->subject->runningADOdbDriver('postgres'));
65  }
66 
71  public function limitIsProperlyRemapped() {
72  $result = $this->subject->SELECTquery('*', 'be_users', '1=1', '', '', '20');
73  $expected = 'SELECT * FROM "be_users" WHERE 1 = 1 LIMIT 20';
74  $this->assertEquals($expected, $this->cleanSql($result));
75  }
76 
81  public function limitWithSkipIsProperlyRemapped() {
82  $result = $this->subject->SELECTquery('*', 'be_users', '1=1', '', '', '20,40');
83  $expected = 'SELECT * FROM "be_users" WHERE 1 = 1 LIMIT 40 OFFSET 20';
84  $this->assertEquals($expected, $this->cleanSql($result));
85  }
86 
91  public function findInSetIsProperlyRemapped() {
92  $result = $this->subject->SELECTquery('*', 'fe_users', 'FIND_IN_SET(10, usergroup)');
93  $expected = 'SELECT * FROM "fe_users" WHERE FIND_IN_SET(10, CAST("usergroup" AS CHAR)) != 0';
94  $this->assertEquals($expected, $this->cleanSql($result));
95  }
96 
102  $result = $this->subject->SELECTquery('*', 'tt_content', 'bodytext LIKE BINARY \'test\'');
103  $expected = 'SELECT * FROM "tt_content" WHERE "bodytext" LIKE \'test\'';
104  $this->assertEquals($expected, $this->cleanSql($result));
105  }
106 
112  $result = $this->subject->SELECTquery('*', 'tt_content', 'bodytext NOT LIKE BINARY \'test\'');
113  $expected = 'SELECT * FROM "tt_content" WHERE "bodytext" NOT LIKE \'test\'';
114  $this->assertEquals($expected, $this->cleanSql($result));
115  }
116 
121  public function likeOperatorIsRemappedToIlike() {
122  $result = $this->subject->SELECTquery('*', 'tt_content', 'bodytext LIKE \'test\'');
123  $expected = 'SELECT * FROM "tt_content" WHERE "bodytext" ILIKE \'test\'';
124  $this->assertEquals($expected, $this->cleanSql($result));
125  }
126 
132  $result = $this->subject->SELECTquery('*', 'tt_content', 'bodytext NOT LIKE \'test\'');
133  $expected = 'SELECT * FROM "tt_content" WHERE "bodytext" NOT ILIKE \'test\'';
134  $this->assertEquals($expected, $this->cleanSql($result));
135  }
136 
142  $result = $this->subject->SELECTquery('*', 'pages', 'pid<>3');
143  $expected = 'SELECT * FROM "pages" WHERE "pid" <> 3';
144  $this->assertEquals($expected, $this->cleanSql($result));
145  }
146 
152  $parseString = 'ALTER TABLE sys_file ADD uid INT(11) NOT NULL AUTO_INCREMENT';
153  $components = $this->subject->SQLparser->_callRef('parseALTERTABLE', $parseString);
154  $this->assertInternalType('array', $components);
155 
156  $result = $this->subject->SQLparser->compileSQL($components);
157  $expected = array('ALTER TABLE "sys_file" ADD COLUMN "uid" SERIAL');
158  $this->assertSame($expected, $this->cleanSql($result));
159  }
160 
161 }
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.