Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.x' into cast_uuid_with_tests_2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
x86demon committed Sep 22, 2023
2 parents 0fe0559 + 612a68c commit db4efbf
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 4 deletions.
1 change: 1 addition & 0 deletions .php-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8.1
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`, `uuid`.
* `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`, `uuid`.
* `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
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,17 @@
}
],
"require": {
"php": ">=7.3",
"doctrine/orm": ">=2.6"
"php": ">=8.0",
"doctrine/orm": ">=2.6, <3.0",
"doctrine/dbal": ">=2.6, <3.0"
},
"require-dev": {
"phpunit/phpunit": "9.*",
"doctrine/data-fixtures": "^1.3",
"symfony/yaml": "5.*",
"symfony/cache": "5.*",
"squizlabs/php_codesniffer": "3.5.*"
"squizlabs/php_codesniffer": "3.5.*",
"doctrine/annotations": ">1.0, <2.0"
},
"autoload": {
"psr-4": {
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 @@ -28,6 +28,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: "string" }
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: "string" }
Expand Down

0 comments on commit db4efbf

Please sign in to comment.