Skip to content
This repository was archived by the owner on Nov 26, 2022. It is now read-only.

Commit 50815e3

Browse files
author
Daniel Opitz
committed
Added raw method to function builder
1 parent 8e820d7 commit 50815e3

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

src/Database/FunctionBuilder.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,15 @@ public function now(): FunctionExpression
115115
{
116116
return new FunctionExpression('NOW()', $this->db->getQuoter());
117117
}
118+
119+
/**
120+
* Returns a Raw Expression.
121+
*
122+
* @param string $value A raw value. Be careful!
123+
* @return RawExp Raw Expression
124+
*/
125+
public function raw(string $value): RawExp
126+
{
127+
return new RawExp($value);
128+
}
118129
}

tests/FunctionBuilderTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,4 +109,17 @@ public function testNow()
109109
$this->assertEquals('NOW()', $func->now());
110110
$this->assertEquals('NOW() AS `alias_field`', $func->now()->alias('alias_field')->getValue());
111111
}
112+
113+
/**
114+
* Test.
115+
*
116+
* @return void
117+
*/
118+
public function testRaw()
119+
{
120+
$func = $this->getConnection()->select()->func();
121+
122+
$this->assertInstanceOf(RawExp::class, $func->raw(''));
123+
$this->assertEquals('value', $func->raw('value')->getValue());
124+
}
112125
}

0 commit comments

Comments
 (0)