oroinc / doctrine-extensions Goto Github PK
View Code? Open in Web Editor NEWCross database doctrine DQL functions for MySQL and PostgreSQL.
License: Other
Cross database doctrine DQL functions for MySQL and PostgreSQL.
License: Other
User Deprecated: PostgreSQLPlatform::getName() is deprecated. Identify platforms by their class. (PostgreSQLPlatform.php:1146 called by AbstractPlatformAwareFunctionNode.php:22, doctrine/dbal#4749, package doctrine/dbal)
User Deprecated: Accessing Doctrine\Common\Lexer\Token properties via ArrayAccess is deprecated, use the value, type or position property instead (Token.php:104 called by DocParser.php:691, doctrine/lexer#79, package doctrine/lexer)
This is just warnings, I didn't find at which version they plan to remove those.
Hello Guys,
First of all congratulations for this amazing project! I'm using the extension and I need to use the math FLOOR
operator. I'm not sure that it would be possible to make it work out of the box. I've added a line like this in my config.yml
:
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: true
dql:
numeric_functions:
floor: Oro\ORM\Query\AST\Functions\SimpleFunction
Then I've added two small classes named Floor
in MySQL
and Postgres
namespaces. Does it make sense for you? If so... Do you believe that a pull request for supporting FLOOR
out of the box would be part of the scope of this project?
I configured weekday
as described in the docs:
doctrine:
orm:
dql:
numeric_functions:
weekday: Oro\ORM\Query\AST\Functions\SimpleFunction
Excerpt from my DQL:
$qb = $this->_em->createQueryBuilder();
$qb->select(array(
'WEEKDAY(tke.date) AS weekDay'
));
The error I get:
Catchable Fatal Error: Argument 1 passed to Oro\ORM\Query\AST\Platform\Functions\PlatformFunctionNode::__construct() must be of the type array, string given, called in /.../vendor/doctrine/orm/lib/Doctrine/ORM/Query/Parser.php on line 3389
I have in my project expression like this new \Doctrine\ORM\Query\Expr\Select('GROUP_CONCAT(CASE WHEN serial.cartItem > 0 THEN serial.number ELSE 0 END)')
which throw exception [Syntax Error] line 0, col 130: Error: Expected Doctrine\ORM\Query\Lexer::T_FROM, got '.'. But the same expression with SUM
function works correct new \ORM\Query\Expr\Select('SUM(CASE WHEN serial.cartItem > 0 THEN serial.number ELSE 0 END)')
. Native query with GROUP_CONCAT
also works correct.
Hi! I would like to include a column like the following on my query:
array_to_string(array_agg(DISTINCT i3_.abbreviation || '-' || i3_.name ), '/') AS sclr10,
I need a CONCAT inside GROUP_CONCAT. I've tested but couldn't achive this with your library. Do you think it's possible?
giving 2 Dates: 2017-02-16 and 2016-10-01 :
the diff is
0 years 4 mons 15 days
TIMESTAMPDIFF('year', '2016-10-01', '2017-02-16') // MySql returns:0 PostgreSql returns:1
TIMESTAMPDIFF('month', '2016-10-01', '2017-02-16') //MySql returns:4 PostgreSql returns:4
This is a problem if someone is trying to calculate people's age. So I changed the year implementation
protected function getDiffForYear(Node $firstDateNode, Node $secondDateNode, SqlWalker $sqlWalker)
{
return sprintf(
'EXTRACT(YEAR FROM (age(%s, %s)))',
$this->getExpressionValue($secondDateNode, $sqlWalker),
$this->getExpressionValue($firstDateNode, $sqlWalker)
);
}
But then the months calculation began to return negative values. So I changed it too... but I did not find an elegant way to solve it.
The thing is that when you get an interval you do not even know witch months are you dealing with
Using the number of days / 30 is close but not quite right
and I'm not even sure how to began to solve the thing with quarters...
I ended up leaving everything as it was, but I changed the name of the function getDiffForYear() to getDiffForYearAux() and only use it for calculate months and quarters as it was before and for years I use my function getDiffForYear()
Maybe someone can find a better solution
I see that this repo is not supported, do you mind I'll start moving functions from here to https://github.com/beberlei/DoctrineExtensions ?
There, they will get more support then here
Doctrine datetime type fields results in object. whereas convert_tz results in string. Is it possible to get the result in object type.
'doctrine' => [
'configuration' => [
'orm_default' => [
'datetime_functions' => [
'date' => 'Oro\ORM\Query\AST\Functions\SimpleFunction',
'time' => 'Oro\ORM\Query\AST\Functions\SimpleFunction',
'timestamp' => 'Oro\ORM\Query\AST\Functions\SimpleFunction',
'convert_tz' => 'Oro\ORM\Query\AST\Functions\DateTime\ConvertTz',
],
'numeric_functions' => [
'timestampdiff' => 'Oro\ORM\Query\AST\Functions\Numeric\TimestampDiff',
'dayofyear' => 'Oro\ORM\Query\AST\Functions\SimpleFunction',
'dayofmonth' => 'Oro\ORM\Query\AST\Functions\SimpleFunction',
'dayofweek' => 'Oro\ORM\Query\AST\Functions\SimpleFunction',
'week' => 'Oro\ORM\Query\AST\Functions\SimpleFunction',
'day' => 'Oro\ORM\Query\AST\Functions\SimpleFunction',
'hour' => 'Oro\ORM\Query\AST\Functions\SimpleFunction',
'minute' => 'Oro\ORM\Query\AST\Functions\SimpleFunction',
'month' => 'Oro\ORM\Query\AST\Functions\SimpleFunction',
'quarter' => 'Oro\ORM\Query\AST\Functions\SimpleFunction',
'second' => 'Oro\ORM\Query\AST\Functions\SimpleFunction',
'year' => 'Oro\ORM\Query\AST\Functions\SimpleFunction',
'sign' => 'Oro\ORM\Query\AST\Functions\Numeric\Sign',
'pow' => 'Oro\ORM\Query\AST\Functions\Numeric\Pow',
],
'string_functions' => [
'group_concat' => 'Oro\ORM\Query\AST\Functions\String\GroupConcat',
'cast' => 'Oro\ORM\Query\AST\Functions\Cast'
]
]
]
]
Hello,
I'm using symfony 2.7.1 and I have some problems to install doctrine-extensions.
I followed the installation steps but symfony throws me that error.
Attempted to load class "Cast" from namespace "Oro\ORM\Query\AST\Functions".
Did you forget a "use" statement for another namespace?
Here is the config.yml file: http://pastebin.com/f9yqMiE9
And here is when I try to add the docttirne configuration: http://pastebin.com/Nq6yWQDg
What can I do to solve that?
Hi,
Is there a plan to add SQLite support?
Thank you.
Currently tests fail because of PHP 7.3 issue in doctrine/orm version 2.4.8 - doctrine/orm#7402, which is fixed only in doctrine/orm version 2.6.x and later:
$ php73 vendor/bin/phpunit --configuration tests/config/mysql.phpunit.xml tests/Oro/Tests/Connection/SetupTest.php
PHPUnit 4.8.36 by Sebastian Bergmann and contributors.
E
Time: 46 ms, Memory: 6.00MB
There was 1 error:
1) Oro\Tests\Connection\SetupTest::testSchemaUp
"continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"?
/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php:2640
/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:158
/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php:817
/tests/Oro/Tests/Connection/TestUtil.php:26
/tests/Oro/Tests/TestCase.php:22
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.
I just used the composer SF2 package search in NetBeans and the package found is named oro/doctrine-extensions
instead of orocrm/doctrine-extensions
mentioned in the Installation docs: https://github.com/orocrm/doctrine-extensions#installation
How come?
This ticket is to track progress towards 2.0 with the main goal being able to drop support of obsolete dependencies:
So the plan for now is to do:
"require": {
"php": ">=7.3.0",
"doctrine/orm": ">=2.7"
},
"require-dev": {
"phpunit/phpunit": "9.*",
and raise the versions of other dev dependencies as applicable.
The feedback and help is always appreciated.
Initial updates are in 2.x branch - diff - Travis build -
Upgrade instructions - UPGRADE.md
Good morning,
I had to don't specify the version master to install the bundle the command-line in the documentation isn't working.
php composer.phar require oro/doctrine-extensions --prefer-dist --update-no-dev
Thks.
I need to cast text
to boolean
as I am accessing JSON properties but the CAST function does not support it. Would this be something you are willing to add / accept a PR for?
edit: this is on Postgres
Cheers
Hello,
It seems to be not possible to use your GROUP_CONCAT DQL method with simple strings args :
For example, i want to generate JSON string with this instruction : GROUP_CONCAT('{report:"',r.label,'", expiration_date:"', ur.expiration_date, '"}').
Function buildTreeArrayexpects that $nodes are sorted by path. However at least on PostgreSQL 9.4.5 result from a query sorted by path might be exactly what one would expect as shown on the screenshot below.
The consequence is that buildTreeArray($nodes) puts dir 1/R1/
and dir 1/R4/
under dir 1 copy/
which is clearly wrong. I think that assumptions about order of $nodes
are too strong in the current version of buildTreeArray()
which results in messed up trees on some DB engines.
I propose we sort nodes in MaterializedPathRepository::getNodesHierarchy()
in PHP.
I needed this function, and quickly created it myself by using the SimpleFunction
convention (same as YEAR
, TIME
, DATE
, etc.).
Worked great, and super simple. Any reason this wasn't added before?
Hi ๐
Thank you for this library!
Do you plan to update to PHP 8?
The Bundle use Doctrine\Common\Inflector\Inflector::classify
that was deprecated since Doctrine ORM 2.7 and has been removed in Doctrine ORM 2.8.
This bundle is no longer working.
In 2.x and master we have some deprecations from Doctrine:
[info] User Deprecated: Method "Doctrine\DBAL\Types\Type::getName()" might add "string" as a native return type declaration in the future. Do the same in child class "Oro\DBAL\Types\MoneyType" now to avoid errors or add an explicit @return annotation to suppress this message.
[info] User Deprecated: Method "Doctrine\DBAL\Types\Type::getSQLDeclaration()" might add "string" as a native return type declaration in the future. Do the same in child class "Oro\DBAL\Types\MoneyType" now to avoid errors or add an explicit @return annotation to suppress this message.
[info] User Deprecated: Method "Doctrine\DBAL\Types\Type::convertToPHPValue()" might add "mixed" as a native return type declaration in the future. Do the same in child class "Oro\DBAL\Types\MoneyType" now to avoid errors or add an explicit @return annotation to suppress this message.
[info] User Deprecated: Method "Doctrine\DBAL\Types\Type::requiresSQLCommentHint()" might add "bool" as a native return type declaration in the future. Do the same in child class "Oro\DBAL\Types\MoneyType" now to avoid errors or add an explicit @return annotation to suppress this message.
New release wasn't add to packagist.
Also: This package is not auto-updated.
As week numbers starts different from country to country - mysql have added a "mode" selector to week.
https://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_week
You have hardcoded to 3 in both mysql and postgresql - would it be possible to change this value, so I could write WEEK(xxx, 1)
in my dql - Right now I just get a "[Syntax Error] line 0, col 65: Error: Expected Doctrine\\ORM\\Query\\Lexer::T_CLOSE_PARENTHESIS, got ','"
In README there is link:
https://www.doctrine-project.org/en/latest/cookbook/dql-user-defined-functions.html
When I click, I see:
Page not found
The page you are looking for could not be found. Take a look at one of the pages below instead.
Home
Projects
Contribute
Community
Blog
https://github.com/beberlei/DoctrineExtensions/blob/master/src/Query/Mysql/DateFormat.php
Oro supports more than berberlei does. I need to use DateFormat
but currently I need to install 2 both packages.
Hi,
aftert using packagist :
composer require oro/doctrine-extensions
i can't find Round.php in Oro\ORM\Query\AST\Functions\Numeric
I assume it must have been forgotten when updating this project on packagist.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.