Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
13532 anikendra 1
<?php
2
/**
3
 * DboPostgresTest file
4
 *
5
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
6
 * Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
7
 *
8
 * Licensed under The MIT License
9
 * Redistributions of files must retain the above copyright notice.
10
 *
11
 * @copyright     Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
12
 * @link          http://cakephp.org CakePHP(tm) Project
13
 * @package       Cake.Test.Case.Model.Datasource.Database
14
 * @since         CakePHP(tm) v 1.2.0
15
 * @license       http://www.opensource.org/licenses/mit-license.php MIT License
16
 */
17
 
18
App::uses('Model', 'Model');
19
App::uses('AppModel', 'Model');
20
App::uses('Postgres', 'Model/Datasource/Database');
21
 
22
require_once dirname(dirname(dirname(__FILE__))) . DS . 'models.php';
23
 
24
/**
25
 * DboPostgresTestDb class
26
 *
27
 * @package       Cake.Test.Case.Model.Datasource.Database
28
 */
29
class DboPostgresTestDb extends Postgres {
30
 
31
/**
32
 * simulated property
33
 *
34
 * @var array
35
 */
36
	public $simulated = array();
37
 
38
/**
39
 * execute method
40
 *
41
 * @param mixed $sql
42
 * @return void
43
 */
44
	protected function _execute($sql, $params = array(), $prepareOptions = array()) {
45
		$this->simulated[] = $sql;
46
		return null;
47
	}
48
 
49
/**
50
 * getLastQuery method
51
 *
52
 * @return void
53
 */
54
	public function getLastQuery() {
55
		return $this->simulated[count($this->simulated) - 1];
56
	}
57
 
58
}
59
 
60
/**
61
 * PostgresTestModel class
62
 *
63
 * @package       Cake.Test.Case.Model.Datasource.Database
64
 */
65
class PostgresTestModel extends Model {
66
 
67
/**
68
 * useTable property
69
 *
70
 * @var boolean
71
 */
72
	public $useTable = false;
73
 
74
/**
75
 * belongsTo property
76
 *
77
 * @var array
78
 */
79
	public $belongsTo = array(
80
		'PostgresClientTestModel' => array(
81
			'foreignKey' => 'client_id'
82
		)
83
	);
84
 
85
/**
86
 * find method
87
 *
88
 * @param mixed $conditions
89
 * @param mixed $fields
90
 * @param mixed $order
91
 * @param mixed $recursive
92
 * @return void
93
 */
94
	public function find($conditions = null, $fields = null, $order = null, $recursive = null) {
95
		return $conditions;
96
	}
97
 
98
/**
99
 * findAll method
100
 *
101
 * @param mixed $conditions
102
 * @param mixed $fields
103
 * @param mixed $order
104
 * @param mixed $recursive
105
 * @return void
106
 */
107
	public function findAll($conditions = null, $fields = null, $order = null, $recursive = null) {
108
		return $conditions;
109
	}
110
 
111
/**
112
 * schema method
113
 *
114
 * @return void
115
 */
116
	public function schema($field = false) {
117
		return array(
118
			'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8'),
119
			'client_id' => array('type' => 'integer', 'null' => '', 'default' => '0', 'length' => '11'),
120
			'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
121
			'login' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
122
			'passwd' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
123
			'addr_1' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
124
			'addr_2' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '25'),
125
			'zip_code' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
126
			'city' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
127
			'country' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
128
			'phone' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
129
			'fax' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
130
			'url' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '255'),
131
			'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
132
			'comments' => array('type' => 'text', 'null' => '1', 'default' => '', 'length' => ''),
133
			'last_login' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
134
			'created' => array('type' => 'date', 'null' => '1', 'default' => '', 'length' => ''),
135
			'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
136
		);
137
	}
138
 
139
}
140
 
141
/**
142
 * PostgresClientTestModel class
143
 *
144
 * @package       Cake.Test.Case.Model.Datasource.Database
145
 */
146
class PostgresClientTestModel extends Model {
147
 
148
/**
149
 * useTable property
150
 *
151
 * @var boolean
152
 */
153
	public $useTable = false;
154
 
155
/**
156
 * schema method
157
 *
158
 * @return void
159
 */
160
	public function schema($field = false) {
161
		return array(
162
			'id' => array('type' => 'integer', 'null' => '', 'default' => '', 'length' => '8', 'key' => 'primary'),
163
			'name' => array('type' => 'string', 'null' => '', 'default' => '', 'length' => '255'),
164
			'email' => array('type' => 'string', 'null' => '1', 'default' => '', 'length' => '155'),
165
			'created' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => ''),
166
			'updated' => array('type' => 'datetime', 'null' => '1', 'default' => '', 'length' => null)
167
		);
168
	}
169
 
170
}
171
 
172
/**
173
 * PostgresTest class
174
 *
175
 * @package       Cake.Test.Case.Model.Datasource.Database
176
 */
177
class PostgresTest extends CakeTestCase {
178
 
179
/**
180
 * Do not automatically load fixtures for each test, they will be loaded manually
181
 * using CakeTestCase::loadFixtures
182
 *
183
 * @var boolean
184
 */
185
	public $autoFixtures = false;
186
 
187
/**
188
 * Fixtures
189
 *
190
 * @var object
191
 */
192
	public $fixtures = array('core.user', 'core.binary_test', 'core.comment', 'core.article',
193
		'core.tag', 'core.articles_tag', 'core.attachment', 'core.person', 'core.post', 'core.author',
194
		'core.datatype',
195
	);
196
 
197
/**
198
 * Actual DB connection used in testing
199
 *
200
 * @var DboSource
201
 */
202
	public $Dbo = null;
203
 
204
/**
205
 * Simulated DB connection used in testing
206
 *
207
 * @var DboSource
208
 */
209
	public $Dbo2 = null;
210
 
211
/**
212
 * Sets up a Dbo class instance for testing
213
 *
214
 */
215
	public function setUp() {
216
		parent::setUp();
217
		Configure::write('Cache.disable', true);
218
		$this->Dbo = ConnectionManager::getDataSource('test');
219
		$this->skipIf(!($this->Dbo instanceof Postgres));
220
		$this->Dbo2 = new DboPostgresTestDb($this->Dbo->config, false);
221
		$this->model = new PostgresTestModel();
222
	}
223
 
224
/**
225
 * Sets up a Dbo class instance for testing
226
 *
227
 */
228
	public function tearDown() {
229
		parent::tearDown();
230
		Configure::write('Cache.disable', false);
231
		unset($this->Dbo2);
232
	}
233
 
234
/**
235
 * Test field quoting method
236
 *
237
 */
238
	public function testFieldQuoting() {
239
		$fields = array(
240
			'"PostgresTestModel"."id" AS "PostgresTestModel__id"',
241
			'"PostgresTestModel"."client_id" AS "PostgresTestModel__client_id"',
242
			'"PostgresTestModel"."name" AS "PostgresTestModel__name"',
243
			'"PostgresTestModel"."login" AS "PostgresTestModel__login"',
244
			'"PostgresTestModel"."passwd" AS "PostgresTestModel__passwd"',
245
			'"PostgresTestModel"."addr_1" AS "PostgresTestModel__addr_1"',
246
			'"PostgresTestModel"."addr_2" AS "PostgresTestModel__addr_2"',
247
			'"PostgresTestModel"."zip_code" AS "PostgresTestModel__zip_code"',
248
			'"PostgresTestModel"."city" AS "PostgresTestModel__city"',
249
			'"PostgresTestModel"."country" AS "PostgresTestModel__country"',
250
			'"PostgresTestModel"."phone" AS "PostgresTestModel__phone"',
251
			'"PostgresTestModel"."fax" AS "PostgresTestModel__fax"',
252
			'"PostgresTestModel"."url" AS "PostgresTestModel__url"',
253
			'"PostgresTestModel"."email" AS "PostgresTestModel__email"',
254
			'"PostgresTestModel"."comments" AS "PostgresTestModel__comments"',
255
			'"PostgresTestModel"."last_login" AS "PostgresTestModel__last_login"',
256
			'"PostgresTestModel"."created" AS "PostgresTestModel__created"',
257
			'"PostgresTestModel"."updated" AS "PostgresTestModel__updated"'
258
		);
259
 
260
		$result = $this->Dbo->fields($this->model);
261
		$expected = $fields;
262
		$this->assertEquals($expected, $result);
263
 
264
		$result = $this->Dbo->fields($this->model, null, 'PostgresTestModel.*');
265
		$expected = $fields;
266
		$this->assertEquals($expected, $result);
267
 
268
		$result = $this->Dbo->fields($this->model, null, array('*', 'AnotherModel.id', 'AnotherModel.name'));
269
		$expected = array_merge($fields, array(
270
			'"AnotherModel"."id" AS "AnotherModel__id"',
271
			'"AnotherModel"."name" AS "AnotherModel__name"'));
272
		$this->assertEquals($expected, $result);
273
 
274
		$result = $this->Dbo->fields($this->model, null, array('*', 'PostgresClientTestModel.*'));
275
		$expected = array_merge($fields, array(
276
			'"PostgresClientTestModel"."id" AS "PostgresClientTestModel__id"',
277
			'"PostgresClientTestModel"."name" AS "PostgresClientTestModel__name"',
278
			'"PostgresClientTestModel"."email" AS "PostgresClientTestModel__email"',
279
			'"PostgresClientTestModel"."created" AS "PostgresClientTestModel__created"',
280
			'"PostgresClientTestModel"."updated" AS "PostgresClientTestModel__updated"'));
281
		$this->assertEquals($expected, $result);
282
	}
283
 
284
/**
285
 * testColumnParsing method
286
 *
287
 * @return void
288
 */
289
	public function testColumnParsing() {
290
		$this->assertEquals('text', $this->Dbo2->column('text'));
291
		$this->assertEquals('date', $this->Dbo2->column('date'));
292
		$this->assertEquals('boolean', $this->Dbo2->column('boolean'));
293
		$this->assertEquals('string', $this->Dbo2->column('character varying'));
294
		$this->assertEquals('time', $this->Dbo2->column('time without time zone'));
295
		$this->assertEquals('datetime', $this->Dbo2->column('timestamp without time zone'));
296
 
297
		$result = $this->Dbo2->column('bigint');
298
		$expected = 'biginteger';
299
		$this->assertEquals($expected, $result);
300
	}
301
 
302
/**
303
 * testValueQuoting method
304
 *
305
 * @return void
306
 */
307
	public function testValueQuoting() {
308
		$this->assertEquals("1.200000", $this->Dbo->value(1.2, 'float'));
309
		$this->assertEquals("'1,2'", $this->Dbo->value('1,2', 'float'));
310
 
311
		$this->assertEquals("0", $this->Dbo->value('0', 'integer'));
312
		$this->assertEquals('NULL', $this->Dbo->value('', 'integer'));
313
		$this->assertEquals('NULL', $this->Dbo->value('', 'float'));
314
		$this->assertEquals("NULL", $this->Dbo->value('', 'integer', false));
315
		$this->assertEquals("NULL", $this->Dbo->value('', 'float', false));
316
		$this->assertEquals("'0.0'", $this->Dbo->value('0.0', 'float'));
317
 
318
		$this->assertEquals("'TRUE'", $this->Dbo->value('t', 'boolean'));
319
		$this->assertEquals("'FALSE'", $this->Dbo->value('f', 'boolean'));
320
		$this->assertEquals("'TRUE'", $this->Dbo->value(true));
321
		$this->assertEquals("'FALSE'", $this->Dbo->value(false));
322
		$this->assertEquals("'t'", $this->Dbo->value('t'));
323
		$this->assertEquals("'f'", $this->Dbo->value('f'));
324
		$this->assertEquals("'TRUE'", $this->Dbo->value('true', 'boolean'));
325
		$this->assertEquals("'FALSE'", $this->Dbo->value('false', 'boolean'));
326
		$this->assertEquals("'FALSE'", $this->Dbo->value('', 'boolean'));
327
		$this->assertEquals("'FALSE'", $this->Dbo->value(0, 'boolean'));
328
		$this->assertEquals("'TRUE'", $this->Dbo->value(1, 'boolean'));
329
		$this->assertEquals("'TRUE'", $this->Dbo->value('1', 'boolean'));
330
		$this->assertEquals("NULL", $this->Dbo->value(null, 'boolean'));
331
		$this->assertEquals("NULL", $this->Dbo->value(array()));
332
	}
333
 
334
/**
335
 * test that localized floats don't cause trouble.
336
 *
337
 * @return void
338
 */
339
	public function testLocalizedFloats() {
340
		$restore = setlocale(LC_NUMERIC, 0);
341
 
342
		$this->skipIf(setlocale(LC_NUMERIC, 'de_DE') === false, "The German locale isn't available.");
343
 
344
		$result = $this->db->value(3.141593, 'float');
345
		$this->assertEquals("3.141593", $result);
346
 
347
		$result = $this->db->value(3.14);
348
		$this->assertEquals("3.140000", $result);
349
 
350
		setlocale(LC_NUMERIC, $restore);
351
	}
352
 
353
/**
354
 * test that date and time columns do not generate errors with null and nullish values.
355
 *
356
 * @return void
357
 */
358
	public function testDateAndTimeAsNull() {
359
		$this->assertEquals('NULL', $this->Dbo->value(null, 'date'));
360
		$this->assertEquals('NULL', $this->Dbo->value('', 'date'));
361
 
362
		$this->assertEquals('NULL', $this->Dbo->value('', 'datetime'));
363
		$this->assertEquals('NULL', $this->Dbo->value(null, 'datetime'));
364
 
365
		$this->assertEquals('NULL', $this->Dbo->value('', 'timestamp'));
366
		$this->assertEquals('NULL', $this->Dbo->value(null, 'timestamp'));
367
 
368
		$this->assertEquals('NULL', $this->Dbo->value('', 'time'));
369
		$this->assertEquals('NULL', $this->Dbo->value(null, 'time'));
370
	}
371
 
372
/**
373
 * Tests that different Postgres boolean 'flavors' are properly returned as native PHP booleans
374
 *
375
 * @return void
376
 */
377
	public function testBooleanNormalization() {
378
		$this->assertEquals(true, $this->Dbo2->boolean('t', false));
379
		$this->assertEquals(true, $this->Dbo2->boolean('true', false));
380
		$this->assertEquals(true, $this->Dbo2->boolean('TRUE', false));
381
		$this->assertEquals(true, $this->Dbo2->boolean(true, false));
382
		$this->assertEquals(true, $this->Dbo2->boolean(1, false));
383
		$this->assertEquals(true, $this->Dbo2->boolean(" ", false));
384
 
385
		$this->assertEquals(false, $this->Dbo2->boolean('f', false));
386
		$this->assertEquals(false, $this->Dbo2->boolean('false', false));
387
		$this->assertEquals(false, $this->Dbo2->boolean('FALSE', false));
388
		$this->assertEquals(false, $this->Dbo2->boolean(false, false));
389
		$this->assertEquals(false, $this->Dbo2->boolean(0, false));
390
		$this->assertEquals(false, $this->Dbo2->boolean('', false));
391
	}
392
 
393
/**
394
 * test that default -> false in schemas works correctly.
395
 *
396
 * @return void
397
 */
398
	public function testBooleanDefaultFalseInSchema() {
399
		$this->loadFixtures('Datatype');
400
 
401
		$model = new Model(array('name' => 'Datatype', 'table' => 'datatypes', 'ds' => 'test'));
402
		$model->create();
403
		$this->assertSame(false, $model->data['Datatype']['bool']);
404
	}
405
 
406
/**
407
 * testLastInsertIdMultipleInsert method
408
 *
409
 * @return void
410
 */
411
	public function testLastInsertIdMultipleInsert() {
412
		$this->loadFixtures('User');
413
		$db1 = ConnectionManager::getDataSource('test');
414
 
415
		$table = $db1->fullTableName('users', false);
416
		$password = '5f4dcc3b5aa765d61d8327deb882cf99';
417
		$db1->execute(
418
			"INSERT INTO {$table} (\"user\", password) VALUES ('mariano', '{$password}')"
419
		);
420
 
421
		$this->assertEquals(5, $db1->lastInsertId($table));
422
 
423
		$db1->execute("INSERT INTO {$table} (\"user\", password) VALUES ('hoge', '{$password}')");
424
		$this->assertEquals(6, $db1->lastInsertId($table));
425
	}
426
 
427
/**
428
 * Tests that column types without default lengths in $columns do not have length values
429
 * applied when generating schemas.
430
 *
431
 * @return void
432
 */
433
	public function testColumnUseLength() {
434
		$result = array('name' => 'foo', 'type' => 'string', 'length' => 100, 'default' => 'FOO');
435
		$expected = '"foo" varchar(100) DEFAULT \'FOO\'';
436
		$this->assertEquals($expected, $this->Dbo->buildColumn($result));
437
 
438
		$result = array('name' => 'foo', 'type' => 'text', 'length' => 100, 'default' => 'FOO');
439
		$expected = '"foo" text DEFAULT \'FOO\'';
440
		$this->assertEquals($expected, $this->Dbo->buildColumn($result));
441
	}
442
 
443
/**
444
 * Tests that binary data is escaped/unescaped properly on reads and writes
445
 *
446
 * @return void
447
 */
448
	public function testBinaryDataIntegrity() {
449
		$this->loadFixtures('BinaryTest');
450
		$data = '%PDF-1.3
451
		%ƒÂÚÂÎßÛ†–ƒ∆
452
		4 0 obj
453
		<< /Length 5 0 R /Filter /FlateDecode >>
454
		stream
455
		xµYMì€∆Ω„WÃ%)nï0¯îâ-«é]Q"πXµáÿ•Ip	-	P V,]Ú#c˚ˇ‰ut¥†∏Ti9 Ü=”›Ø_˜4>à∑‚Épcé¢Pxæ®2q\'
456
		1UªbUᡒ+ö«√[ıµ⁄ão"R∑"HiGæä€(å≠≈^Ãøsm?YlƒÃõªfi‹âEÚB&‚Î◊7bÒ^¸m°÷˛?2±Øs“fiu#®U√ˇú÷g¥C;ä")n})JºIÔ3ËSnÑÎ¥≤ıD∆¢∂Msx1üèG˚±Œ™⁄>¶ySïufØ ˝¸?UπÃã√6flÌÚC=øK?˝…s
457
		˛§¯ˇ:-˜ò7€ÓFæ∂∑Õ˛∆“V’>ılflëÅd«ÜQdI›ÎB%W¿ΩıÉn~hvêCS>«é˛(ØôK!€¡zB!√
458
		[œÜ"ûß ·iH¸[Àºæ∑¯¡L,ÀÚAlS∫ˆ=∫Œ≤cÄr&ˆÈ:√ÿ£˚È«4fl•À]vc›bÅôÿî=siXe4/¡p]ã]ôÆIœ™ Ωflà_ƒ‚G?«7	ùÿ ı¯K4ïIpV◊÷·\'éµóªÚæ>î
459
		;›sú!2fl¬F•/f∑j£
460
		dw"IÊÜπ<ôÿˆ%IG1ytÛDflXg|Éòa§˜}C˛¿ÿe°G´Ú±jÍm~¿/∂hã<#-¥•ıùe87€t˜õ6w}´{æ
461
		m‹ê–	∆¡ 6⁄\
462
		rAÀBùZ3aË‚r$G·$ó0ÑüâUY4È™¡%C∑Ÿ2rc<Iõ-cï.
463
		[ŒöâFA†É‡+QglMÉîÉÄúÌ|¸»#x7¥«MgVÎ-GGÚ• I?Á‘”Lzw∞pHů◊nefqCî.nÕeè∆ÿÛy¡˙fb≤üŒHÜAëÕNq=´@	’cQdÖúAÉIqñŸ˘+2&∏  Àù.gÅ‚ƒœ3EPƒOi—‰:>ÍCäı
464
		=Õec=ëR˝”eñ=<V$ì˙+x+¢ïÒÕ<àeWå»–˚∫Õd§&£àf ]fPA´âtënöå∏◊ó„Ë@∆≠K´÷˘}a_CI˚©yòHg,ôSSVìBƒl4 L.ÈY…á,2∂íäÙ.$ó¸CäŸ*€óy
465
		π?G,_√·ÆÎç=^Vkvo±ó{§ƒ2»±¨Ïüo»ëD-ãé fió¥cVÙ\'™G~\'p¢%* ã˚÷
466
		ªºnh˚ºO^∏…®[Ó“‚ÅfıÌ≥∫F!Eœ(π∑T6`¬tΩÆ0ì»rTÎ`»Ñ«
467
		]≈åp˝)=¿Ô0∆öVÂmˇˆ„ø~¯ÁÔ∏b*fc»‡Îı„Ú}∆tœs∂Y∫ÜaÆ˙X∏~<ÿ·Ùvé1‹p¿TD∆ÔîÄ“úhˆ*Ú€îe)K–p¨ÚJ3Ÿ∞ã>ÊuNê°“√Ü ‹Ê9iÙ0˙AAEÍ ˙`∂£\'ûce•åƒX›ŸÁ´1SK{qdá"tÏ[wQ#SµBe∞∑µó…ÌV`B"Ñ≥„!è_Óφ-º*ºú¿Ë0ˆeê∂´ë+HFj…‡zvHÓN|ÔL÷ûñ3õÜ$z%sá…pÎóV38âs	Çoµ•ß3†<9B·¨û~¢3)ÂxóÿÁCÕòÆ∫Í=»ÿSπS;∆~±êÆTEp∑óÈ÷ÀuìDHÈ$ÉõæÜjû§"≤ÃONM®RËíRr{õS	∏Ê™op±W;ÂUÔ P∫kÔˇflTæ∑óflË”ÆC©Ô[≥◊HÁ˚¨hê"ÆbF?ú%h˙ˇ4xèÕ(ó2ÙáíM])Ñd|=fë-cI0ñL¢kÖêk‰Rƒ«ıÄWñ8mO3∏&√æËX¯Hó—ì]yF2»–˜ádàà‡‹Çο„≥7mªHAS∑¶.;Œx(1} _kd©.fidç48M\'àáªCp^Krí<ɉXÓıïl!Ì$N<ı∞B»G]…∂Ó¯>˛ÔbõÒπÀ•:ôO<j∂™œ%âÏ—>@È$pÖu‹Ê´-QqV ?V≥JÆÍqÛX8(lπï@zgÖ}Fe<ˇ‡Sñ“ÿ˜ê?6‡L∫Oß~µ –?ËeäÚ®YîÕ=Ü=¢DÁu*GvBk;)L¬N«î:flö∂≠ÇΩq„Ñm하Ë∂‚"û≥§:±≤i^ΩÑ!)Wıyŧô á„RÄ÷Òôc’≠—s™rı‚Pdêãh˘ßHVç5fifiÈF€çÌÛuçÖ/M=gëµ±ÿGû1coÔuñæ‘z®. õ∑7ÉÏÜÆ,°’H†ÍÉÌ∂7e	º® íˆ⁄◊øNWK”ÂYµ‚ñé;µ¶gV-fl>µtË¥áßN2 ¯¶BaP-)eW.àôt^∏1›C∑Ö?L„&”5’4jvã–ªZ	÷+4% ´0l…»ú^°´© ûiπ∑é®óܱÒÿ‰ïˆÌ–dˆ◊Æ19rQ=Í|ı•rMæ¬;ò‰Y‰é9.”‹˝V«ã¯∏,+ë®j*¡·/';
468
 
469
		$model = new AppModel(array('name' => 'BinaryTest', 'ds' => 'test'));
470
		$model->save(compact('data'));
471
 
472
		$result = $model->find('first');
473
		$this->assertEquals($data, $result['BinaryTest']['data']);
474
	}
475
 
476
/**
477
 * Tests passing PostgreSQL regular expression operators when building queries
478
 *
479
 * @return void
480
 */
481
	public function testRegexpOperatorConditionsParsing() {
482
		$this->assertSame(' WHERE "name" ~ \'[a-z_]+\'', $this->Dbo->conditions(array('name ~' => '[a-z_]+')));
483
		$this->assertSame(' WHERE "name" ~* \'[a-z_]+\'', $this->Dbo->conditions(array('name ~*' => '[a-z_]+')));
484
		$this->assertSame(' WHERE "name" !~ \'[a-z_]+\'', $this->Dbo->conditions(array('name !~' => '[a-z_]+')));
485
		$this->assertSame(' WHERE "name" !~* \'[a-z_]+\'', $this->Dbo->conditions(array('name !~*' => '[a-z_]+')));
486
	}
487
 
488
/**
489
 * Tests the syntax of generated schema indexes
490
 *
491
 * @return void
492
 */
493
	public function testSchemaIndexSyntax() {
494
		$schema = new CakeSchema();
495
		$schema->tables = array('i18n' => array(
496
			'id' => array(
497
				'type' => 'integer', 'null' => false, 'default' => null,
498
				'length' => 10, 'key' => 'primary'
499
			),
500
			'locale' => array('type' => 'string', 'null' => false, 'length' => 6, 'key' => 'index'),
501
			'model' => array('type' => 'string', 'null' => false, 'key' => 'index'),
502
			'foreign_key' => array(
503
				'type' => 'integer', 'null' => false, 'length' => 10, 'key' => 'index'
504
			),
505
			'field' => array('type' => 'string', 'null' => false, 'key' => 'index'),
506
			'content' => array('type' => 'text', 'null' => true, 'default' => null),
507
			'indexes' => array(
508
				'PRIMARY' => array('column' => 'id', 'unique' => 1),
509
				'locale' => array('column' => 'locale', 'unique' => 0),
510
				'model' => array('column' => 'model', 'unique' => 0),
511
				'row_id' => array('column' => 'foreign_key', 'unique' => 0),
512
				'field' => array('column' => 'field', 'unique' => 0)
513
			)
514
		));
515
 
516
		$result = $this->Dbo->createSchema($schema);
517
		$this->assertNotRegExp('/^CREATE INDEX(.+);,$/', $result);
518
	}
519
 
520
/**
521
 * testCakeSchema method
522
 *
523
 * Test that schema generated postgresql queries are valid. ref #5696
524
 * Check that the create statement for a schema generated table is the same as the original sql
525
 *
526
 * @return void
527
 */
528
	public function testCakeSchema() {
529
		$db1 = ConnectionManager::getDataSource('test');
530
		$db1->cacheSources = false;
531
 
532
		$db1->rawQuery('CREATE TABLE ' . $db1->fullTableName('datatype_tests') . ' (
533
			id serial NOT NULL,
534
			"varchar" character varying(40) NOT NULL,
535
			"full_length" character varying NOT NULL,
536
			"huge_int" bigint NOT NULL,
537
			"timestamp" timestamp without time zone,
538
			"date" date,
539
			CONSTRAINT test_data_types_pkey PRIMARY KEY (id)
540
		)');
541
 
542
		$schema = new CakeSchema(array('connection' => 'test'));
543
		$result = $schema->read(array(
544
			'connection' => 'test',
545
			'models' => array('DatatypeTest')
546
		));
547
		$schema->tables = array(
548
			'datatype_tests' => $result['tables']['missing']['datatype_tests']
549
		);
550
		$result = $db1->createSchema($schema, 'datatype_tests');
551
 
552
		$this->assertNotRegExp('/timestamp DEFAULT/', $result);
553
		$this->assertRegExp('/\"full_length\"\s*text\s.*,/', $result);
554
		$this->assertContains('timestamp ,', $result);
555
		$this->assertContains('"huge_int" bigint NOT NULL,', $result);
556
 
557
		$db1->query('DROP TABLE ' . $db1->fullTableName('datatype_tests'));
558
 
559
		$db1->query($result);
560
		$result2 = $schema->read(array(
561
			'connection' => 'test',
562
			'models' => array('DatatypeTest')
563
		));
564
		$schema->tables = array('datatype_tests' => $result2['tables']['missing']['datatype_tests']);
565
		$result2 = $db1->createSchema($schema, 'datatype_tests');
566
		$this->assertEquals($result, $result2);
567
 
568
		$db1->query('DROP TABLE ' . $db1->fullTableName('datatype_tests'));
569
	}
570
 
571
/**
572
 * Test index generation from table info.
573
 *
574
 * @return void
575
 */
576
	public function testIndexGeneration() {
577
		$name = $this->Dbo->fullTableName('index_test', false, false);
578
		$this->Dbo->query('CREATE TABLE ' . $name . ' ("id" serial NOT NULL PRIMARY KEY, "bool" integer, "small_char" varchar(50), "description" varchar(40) )');
579
		$this->Dbo->query('CREATE INDEX pointless_bool ON ' . $name . '("bool")');
580
		$this->Dbo->query('CREATE UNIQUE INDEX char_index ON ' . $name . '("small_char")');
581
		$expected = array(
582
			'PRIMARY' => array('unique' => true, 'column' => 'id'),
583
			'pointless_bool' => array('unique' => false, 'column' => 'bool'),
584
			'char_index' => array('unique' => true, 'column' => 'small_char'),
585
		);
586
		$result = $this->Dbo->index($name);
587
		$this->Dbo->query('DROP TABLE ' . $name);
588
		$this->assertEquals($expected, $result);
589
 
590
		$name = $this->Dbo->fullTableName('index_test_2', false, false);
591
		$this->Dbo->query('CREATE TABLE ' . $name . ' ("id" serial NOT NULL PRIMARY KEY, "bool" integer, "small_char" varchar(50), "description" varchar(40) )');
592
		$this->Dbo->query('CREATE UNIQUE INDEX multi_col ON ' . $name . '("small_char", "bool")');
593
		$expected = array(
594
			'PRIMARY' => array('unique' => true, 'column' => 'id'),
595
			'multi_col' => array('unique' => true, 'column' => array('small_char', 'bool')),
596
		);
597
		$result = $this->Dbo->index($name);
598
		$this->Dbo->query('DROP TABLE ' . $name);
599
		$this->assertEquals($expected, $result);
600
	}
601
 
602
/**
603
 * Test the alterSchema capabilities of postgres
604
 *
605
 * @return void
606
 */
607
	public function testAlterSchema() {
608
		$Old = new CakeSchema(array(
609
			'connection' => 'test',
610
			'name' => 'AlterPosts',
611
			'alter_posts' => array(
612
				'id' => array('type' => 'integer', 'key' => 'primary'),
613
				'author_id' => array('type' => 'integer', 'null' => false),
614
				'title' => array('type' => 'string', 'null' => true),
615
				'body' => array('type' => 'text'),
616
				'published' => array('type' => 'string', 'length' => 1, 'default' => 'N'),
617
				'created' => array('type' => 'datetime'),
618
				'updated' => array('type' => 'datetime'),
619
			)
620
		));
621
		$this->Dbo->query($this->Dbo->createSchema($Old));
622
 
623
		$New = new CakeSchema(array(
624
			'connection' => 'test',
625
			'name' => 'AlterPosts',
626
			'alter_posts' => array(
627
				'id' => array('type' => 'integer', 'key' => 'primary'),
628
				'author_id' => array('type' => 'integer', 'null' => true),
629
				'title' => array('type' => 'string', 'null' => false, 'default' => 'my title'),
630
				'body' => array('type' => 'string', 'length' => 500),
631
				'status' => array('type' => 'integer', 'length' => 3, 'default' => 1),
632
				'created' => array('type' => 'datetime'),
633
				'updated' => array('type' => 'datetime'),
634
			)
635
		));
636
		$this->Dbo->query($this->Dbo->alterSchema($New->compare($Old), 'alter_posts'));
637
 
638
		$model = new CakeTestModel(array('table' => 'alter_posts', 'ds' => 'test'));
639
		$result = $model->schema();
640
		$this->assertTrue(isset($result['status']));
641
		$this->assertFalse(isset($result['published']));
642
		$this->assertEquals('string', $result['body']['type']);
643
		$this->assertEquals(1, $result['status']['default']);
644
		$this->assertEquals(true, $result['author_id']['null']);
645
		$this->assertEquals(false, $result['title']['null']);
646
 
647
		$this->Dbo->query($this->Dbo->dropSchema($New));
648
 
649
		$New = new CakeSchema(array(
650
			'connection' => 'test_suite',
651
			'name' => 'AlterPosts',
652
			'alter_posts' => array(
653
				'id' => array('type' => 'string', 'length' => 36, 'key' => 'primary'),
654
				'author_id' => array('type' => 'integer', 'null' => false),
655
				'title' => array('type' => 'string', 'null' => true),
656
				'body' => array('type' => 'text'),
657
				'published' => array('type' => 'string', 'length' => 1, 'default' => 'N'),
658
				'created' => array('type' => 'datetime'),
659
				'updated' => array('type' => 'datetime'),
660
			)
661
		));
662
		$result = $this->Dbo->alterSchema($New->compare($Old), 'alter_posts');
663
		$this->assertNotRegExp('/varchar\(36\) NOT NULL/i', $result);
664
	}
665
 
666
/**
667
 * Test the alter index capabilities of postgres
668
 *
669
 * @return void
670
 */
671
	public function testAlterIndexes() {
672
		$this->Dbo->cacheSources = false;
673
 
674
		$schema1 = new CakeSchema(array(
675
			'name' => 'AlterTest1',
676
			'connection' => 'test',
677
			'altertest' => array(
678
				'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
679
				'name' => array('type' => 'string', 'null' => false, 'length' => 50),
680
				'group1' => array('type' => 'integer', 'null' => true),
681
				'group2' => array('type' => 'integer', 'null' => true)
682
			)
683
		));
684
 
685
		$this->Dbo->rawQuery($this->Dbo->createSchema($schema1));
686
 
687
		$schema2 = new CakeSchema(array(
688
			'name' => 'AlterTest2',
689
			'connection' => 'test',
690
			'altertest' => array(
691
				'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
692
				'name' => array('type' => 'string', 'null' => false, 'length' => 50),
693
				'group1' => array('type' => 'integer', 'null' => true),
694
				'group2' => array('type' => 'integer', 'null' => true),
695
				'indexes' => array(
696
					'name_idx' => array('unique' => false, 'column' => 'name'),
697
					'group_idx' => array('unique' => false, 'column' => 'group1'),
698
					'compound_idx' => array('unique' => false, 'column' => array('group1', 'group2')),
699
					'PRIMARY' => array('unique' => true, 'column' => 'id')
700
				)
701
			)
702
		));
703
		$this->Dbo->query($this->Dbo->alterSchema($schema2->compare($schema1)));
704
 
705
		$indexes = $this->Dbo->index('altertest');
706
		$this->assertEquals($schema2->tables['altertest']['indexes'], $indexes);
707
 
708
		// Change three indexes, delete one and add another one
709
		$schema3 = new CakeSchema(array(
710
			'name' => 'AlterTest3',
711
			'connection' => 'test',
712
			'altertest' => array(
713
				'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
714
				'name' => array('type' => 'string', 'null' => false, 'length' => 50),
715
				'group1' => array('type' => 'integer', 'null' => true),
716
				'group2' => array('type' => 'integer', 'null' => true),
717
				'indexes' => array(
718
					'name_idx' => array('unique' => true, 'column' => 'name'),
719
					'group_idx' => array('unique' => false, 'column' => 'group2'),
720
					'compound_idx' => array('unique' => false, 'column' => array('group2', 'group1')),
721
					'another_idx' => array('unique' => false, 'column' => array('group1', 'name')))
722
		)));
723
 
724
		$this->Dbo->query($this->Dbo->alterSchema($schema3->compare($schema2)));
725
 
726
		$indexes = $this->Dbo->index('altertest');
727
		$this->assertEquals($schema3->tables['altertest']['indexes'], $indexes);
728
 
729
		// Compare us to ourself.
730
		$this->assertEquals(array(), $schema3->compare($schema3));
731
 
732
		// Drop the indexes
733
		$this->Dbo->query($this->Dbo->alterSchema($schema1->compare($schema3)));
734
 
735
		$indexes = $this->Dbo->index('altertest');
736
		$this->assertEquals(array(), $indexes);
737
 
738
		$this->Dbo->query($this->Dbo->dropSchema($schema1));
739
	}
740
 
741
/**
742
 * Test the alterSchema RENAME statements
743
 *
744
 * @return void
745
 */
746
	public function testAlterSchemaRenameTo() {
747
		$query = $this->Dbo->alterSchema(array(
748
			'posts' => array(
749
				'change' => array(
750
					'title' => array('name' => 'subject', 'type' => 'string', 'null' => false)
751
				)
752
			)
753
		));
754
		$this->assertContains('RENAME "title" TO "subject";', $query);
755
		$this->assertContains('ALTER COLUMN "subject" TYPE', $query);
756
		$this->assertNotContains(";\n\tALTER COLUMN \"subject\" TYPE", $query);
757
		$this->assertNotContains('ALTER COLUMN "title" TYPE "subject"', $query);
758
	}
759
 
760
/**
761
 * Test it is possible to use virtual field with postgresql
762
 *
763
 * @return void
764
 */
765
	public function testVirtualFields() {
766
		$this->loadFixtures('Article', 'Comment', 'User', 'Attachment', 'Tag', 'ArticlesTag');
767
		$Article = new Article;
768
		$Article->virtualFields = array(
769
			'next_id' => 'Article.id + 1',
770
			'complex' => 'Article.title || Article.body',
771
			'functional' => 'COALESCE(User.user, Article.title)',
772
			'subquery' => 'SELECT count(*) FROM ' . $Article->Comment->table
773
		);
774
		$result = $Article->find('first');
775
		$this->assertEquals(2, $result['Article']['next_id']);
776
		$this->assertEquals($result['Article']['complex'], $result['Article']['title'] . $result['Article']['body']);
777
		$this->assertEquals($result['Article']['functional'], $result['User']['user']);
778
		$this->assertEquals(6, $result['Article']['subquery']);
779
	}
780
 
781
/**
782
 * Test that virtual fields work with SQL constants
783
 *
784
 * @return void
785
 */
786
	public function testVirtualFieldAsAConstant() {
787
		$this->loadFixtures('Article', 'Comment');
788
		$Article = ClassRegistry::init('Article');
789
		$Article->virtualFields = array(
790
			'empty' => "NULL",
791
			'number' => 43,
792
			'truth' => 'TRUE'
793
		);
794
		$result = $Article->find('first');
795
		$this->assertNull($result['Article']['empty']);
796
		$this->assertTrue($result['Article']['truth']);
797
		$this->assertEquals(43, $result['Article']['number']);
798
	}
799
 
800
/**
801
 * Tests additional order options for postgres
802
 *
803
 * @return void
804
 */
805
	public function testOrderAdditionalParams() {
806
		$result = $this->Dbo->order(array('title' => 'DESC NULLS FIRST', 'body' => 'DESC'));
807
		$expected = ' ORDER BY "title" DESC NULLS FIRST, "body" DESC';
808
		$this->assertEquals($expected, $result);
809
	}
810
 
811
/**
812
 * Test it is possible to do a SELECT COUNT(DISTINCT Model.field)
813
 * query in postgres and it gets correctly quoted
814
 *
815
 * @return void
816
 */
817
	public function testQuoteDistinctInFunction() {
818
		$this->loadFixtures('Article');
819
		$Article = new Article;
820
		$result = $this->Dbo->fields($Article, null, array('COUNT(DISTINCT Article.id)'));
821
		$expected = array('COUNT(DISTINCT "Article"."id")');
822
		$this->assertEquals($expected, $result);
823
 
824
		$result = $this->Dbo->fields($Article, null, array('COUNT(DISTINCT id)'));
825
		$expected = array('COUNT(DISTINCT "id")');
826
		$this->assertEquals($expected, $result);
827
 
828
		$result = $this->Dbo->fields($Article, null, array('COUNT(DISTINCT FUNC(id))'));
829
		$expected = array('COUNT(DISTINCT FUNC("id"))');
830
		$this->assertEquals($expected, $result);
831
	}
832
 
833
/**
834
 * test that saveAll works even with conditions that lack a model name.
835
 *
836
 * @return void
837
 */
838
	public function testUpdateAllWithNonQualifiedConditions() {
839
		$this->loadFixtures('Article');
840
		$Article = new Article();
841
		$result = $Article->updateAll(array('title' => "'Awesome'"), array('title' => 'Third Article'));
842
		$this->assertTrue($result);
843
 
844
		$result = $Article->find('count', array(
845
			'conditions' => array('Article.title' => 'Awesome')
846
		));
847
		$this->assertEquals(1, $result, 'Article count is wrong or fixture has changed.');
848
	}
849
 
850
/**
851
 * test alterSchema on two tables.
852
 *
853
 * @return void
854
 */
855
	public function testAlteringTwoTables() {
856
		$schema1 = new CakeSchema(array(
857
			'name' => 'AlterTest1',
858
			'connection' => 'test',
859
			'altertest' => array(
860
				'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
861
				'name' => array('type' => 'string', 'null' => false, 'length' => 50),
862
			),
863
			'other_table' => array(
864
				'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
865
				'name' => array('type' => 'string', 'null' => false, 'length' => 50),
866
			)
867
		));
868
		$schema2 = new CakeSchema(array(
869
			'name' => 'AlterTest1',
870
			'connection' => 'test',
871
			'altertest' => array(
872
				'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
873
				'field_two' => array('type' => 'string', 'null' => false, 'length' => 50),
874
			),
875
			'other_table' => array(
876
				'id' => array('type' => 'integer', 'null' => false, 'default' => 0),
877
				'field_two' => array('type' => 'string', 'null' => false, 'length' => 50),
878
			)
879
		));
880
		$result = $this->db->alterSchema($schema2->compare($schema1));
881
		$this->assertEquals(2, substr_count($result, 'field_two'), 'Too many fields');
882
		$this->assertFalse(strpos(';ALTER', $result), 'Too many semi colons');
883
	}
884
 
885
/**
886
 * test encoding setting.
887
 *
888
 * @return void
889
 */
890
	public function testEncoding() {
891
		$result = $this->Dbo->setEncoding('UTF8');
892
		$this->assertTrue($result);
893
 
894
		$result = $this->Dbo->getEncoding();
895
		$this->assertEquals('UTF8', $result);
896
 
897
		$result = $this->Dbo->setEncoding('EUC_JP'); /* 'EUC_JP' is right character code name in PostgreSQL */
898
		$this->assertTrue($result);
899
 
900
		$result = $this->Dbo->getEncoding();
901
		$this->assertEquals('EUC_JP', $result);
902
	}
903
 
904
/**
905
 * Test truncate with a mock.
906
 *
907
 * @return void
908
 */
909
	public function testTruncateStatements() {
910
		$this->loadFixtures('Article', 'User');
911
		$db = ConnectionManager::getDatasource('test');
912
		$schema = $db->config['schema'];
913
		$Article = new Article();
914
 
915
		$this->Dbo = $this->getMock('Postgres', array('execute'), array($db->config));
916
 
917
		$this->Dbo->expects($this->at(0))->method('execute')
918
			->with("DELETE FROM \"$schema\".\"articles\"");
919
		$this->Dbo->truncate($Article);
920
 
921
		$this->Dbo->expects($this->at(0))->method('execute')
922
			->with("DELETE FROM \"$schema\".\"articles\"");
923
		$this->Dbo->truncate('articles');
924
 
925
		// #2355: prevent duplicate prefix
926
		$this->Dbo->config['prefix'] = 'tbl_';
927
		$Article->tablePrefix = 'tbl_';
928
		$this->Dbo->expects($this->at(0))->method('execute')
929
			->with("DELETE FROM \"$schema\".\"tbl_articles\"");
930
		$this->Dbo->truncate($Article);
931
 
932
		$this->Dbo->expects($this->at(0))->method('execute')
933
			->with("DELETE FROM \"$schema\".\"tbl_articles\"");
934
		$this->Dbo->truncate('articles');
935
	}
936
 
937
/**
938
 * Test nested transaction
939
 *
940
 * @return void
941
 */
942
	public function testNestedTransaction() {
943
		$this->Dbo->useNestedTransactions = true;
944
		$this->skipIf($this->Dbo->nestedTransactionSupported() === false, 'The Postgres server do not support nested transaction');
945
 
946
		$this->loadFixtures('Article');
947
		$model = new Article();
948
		$model->hasOne = $model->hasMany = $model->belongsTo = $model->hasAndBelongsToMany = array();
949
		$model->cacheQueries = false;
950
		$this->Dbo->cacheMethods = false;
951
 
952
		$this->assertTrue($this->Dbo->begin());
953
		$this->assertNotEmpty($model->read(null, 1));
954
 
955
		$this->assertTrue($this->Dbo->begin());
956
		$this->assertTrue($model->delete(1));
957
		$this->assertEmpty($model->read(null, 1));
958
		$this->assertTrue($this->Dbo->rollback());
959
		$this->assertNotEmpty($model->read(null, 1));
960
 
961
		$this->assertTrue($this->Dbo->begin());
962
		$this->assertTrue($model->delete(1));
963
		$this->assertEmpty($model->read(null, 1));
964
		$this->assertTrue($this->Dbo->commit());
965
		$this->assertEmpty($model->read(null, 1));
966
 
967
		$this->assertTrue($this->Dbo->rollback());
968
		$this->assertNotEmpty($model->read(null, 1));
969
	}
970
 
971
	public function testResetSequence() {
972
		$model = new Article();
973
 
974
		$table = $this->Dbo->fullTableName($model, false);
975
		$fields = array(
976
			'id', 'user_id', 'title', 'body', 'published',
977
		);
978
		$values = array(
979
			array(1, 1, 'test', 'first post', false),
980
			array(2, 1, 'test 2', 'second post post', false),
981
		);
982
		$this->Dbo->insertMulti($table, $fields, $values);
983
		$sequence = $this->Dbo->getSequence($table);
984
		$result = $this->Dbo->rawQuery("SELECT nextval('$sequence')");
985
		$original = $result->fetch(PDO::FETCH_ASSOC);
986
 
987
		$this->assertTrue($this->Dbo->resetSequence($table, 'id'));
988
		$result = $this->Dbo->rawQuery("SELECT currval('$sequence')");
989
		$new = $result->fetch(PDO::FETCH_ASSOC);
990
		$this->assertTrue($new['currval'] > $original['nextval'], 'Sequence did not update');
991
	}
992
 
993
	public function testSettings() {
994
		Configure::write('Cache.disable', true);
995
		$this->Dbo = ConnectionManager::getDataSource('test');
996
		$this->skipIf(!($this->Dbo instanceof Postgres));
997
 
998
		$config2 = $this->Dbo->config;
999
		$config2['settings']['datestyle'] = 'sql, dmy';
1000
		ConnectionManager::create('test2', $config2);
1001
		$dbo2 = new Postgres($config2, true);
1002
		$expected = array(array('r' => date('d/m/Y')));
1003
		$r = $dbo2->fetchRow('SELECT now()::date AS "r"');
1004
		$this->assertEquals($expected, $r);
1005
		$dbo2->execute('SET DATESTYLE TO ISO');
1006
		$dbo2->disconnect();
1007
	}
1008
 
1009
/**
1010
 * Test the limit function.
1011
 *
1012
 * @return void
1013
 */
1014
	public function testLimit() {
1015
		$db = $this->Dbo;
1016
 
1017
		$result = $db->limit('0');
1018
		$this->assertNull($result);
1019
 
1020
		$result = $db->limit('10');
1021
		$this->assertEquals(' LIMIT 10', $result);
1022
 
1023
		$result = $db->limit('FARTS', 'BOOGERS');
1024
		$this->assertEquals(' LIMIT 0 OFFSET 0', $result);
1025
 
1026
		$result = $db->limit(20, 10);
1027
		$this->assertEquals(' LIMIT 20 OFFSET 10', $result);
1028
 
1029
		$result = $db->limit(10, 300000000000000000000000000000);
1030
		$scientificNotation = sprintf('%.1E', 300000000000000000000000000000);
1031
		$this->assertNotContains($scientificNotation, $result);
1032
	}
1033
 
1034
}