Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Available functions:
* `ROUND(value, ?precision)` - Rounds the value to the specified precision (defaults to 0 precision if not specified).
* `CEIL(value)` - Returns the value rounded up.
* `SIGN(expr)` - Returns the sign of the argument.
* `CAST(expr as type)` - Takes an expression of any type and produces a result value of a specified type. Supported types are: `char`, `string`, `text`, `date`, `datetime`, `time`, `int`, `integer`, `decimal`, `boolean`, `binary`.
* `CAST(expr as type)` - Takes an expression of any type and produces a result value of a specified type. Supported types are: `char`, `string`, `text`, `date`, `datetime`, `time`, `int`, `integer`, `bigint`, `decimal`, `boolean`, `binary`.
* `CONCAT_WS` - Concatenate all but the first argument. The first argument is used as the separator string.
* `GROUP_CONCAT` - Returns a concatenated string. GROUP_CONCAT full syntax:
```
Expand Down
1 change: 1 addition & 0 deletions src/Oro/ORM/Query/AST/Functions/Cast.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Cast extends AbstractPlatformAwareFunctionNode
'time',
'int',
'integer',
'bigint',
'decimal',
'json',
'bool',
Expand Down
2 changes: 2 additions & 0 deletions src/Oro/ORM/Query/AST/Platform/Functions/Mysql/Cast.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ public function getSql(SqlWalker $sqlWalker): string
$type = 'char';
} elseif ($type === 'int' || $type === 'integer' || $isBoolean) {
$type = 'signed';
} elseif ($type === 'bigint') {
$type = 'unsigned';
}

$expression = 'CAST(' . $this->getExpressionValue($value, $sqlWalker) . ' AS ' . $type . ')';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
expectedResult:
- 123

#BIGINT
- functions:
- { name: "cast", className: "Oro\\ORM\\Query\\AST\\Functions\\Cast", type: "numeric" }
dql: "SELECT CAST('9223372036854775807' as bigint) FROM Oro\\Entities\\Foo f WHERE f.id = 1"
sql: "SELECT CAST('9223372036854775807' AS unsigned) AS sclr_0 FROM test_foo t0_ WHERE t0_.id = 1"
expectedResult:
- 9223372036854775807

#CHAR
- functions:
- { name: "cast", className: "Oro\\ORM\\Query\\AST\\Functions\\Cast", type: "numeric" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@
expectedResult:
- 123

#BIGINT
- functions:
- { name: "cast", className: "Oro\\ORM\\Query\\AST\\Functions\\Cast", type: "numeric" }
dql: "SELECT CAST('9223372036854775807' as bigint) FROM Oro\\Entities\\Foo f WHERE f.id = 1"
sql: "SELECT CAST('9223372036854775807' AS bigint) AS sclr_0 FROM test_foo t0_ WHERE t0_.id = 1"
expectedResult:
- 9223372036854775807

#CHAR
- functions:
- { name: "cast", className: "Oro\\ORM\\Query\\AST\\Functions\\Cast", type: "numeric" }
Expand Down

0 comments on commit 478101f

Please sign in to comment.