Git Product home page Git Product logo

doctrine-extensions's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

doctrine-extensions's Issues

Doctrine deprecations

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.

FLOOR support

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?

Cannot use weekday numeric function Argument 1must be of the type array, string given

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

GROUP_CONCAT and CASE WHEN

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.

GROUP_CONCAT + concat

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?

problem with TIMESTAMPDIFF postgresql implementation

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

Zend Framework 2 config instructions

'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'
            ]
        ]
    ]
]

doctrine-extensions installation error

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?

Enable tests on PHP >=7.3

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.

2.x progress

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.

Current Status:

Initial updates are in 2.x branch - diff - Travis build - Travis build status on 2.x
Upgrade instructions - UPGRADE.md

master version is not unstallable from komposer

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.

CAST function - unspported type boolean

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

GROUP_CONCAT With string and not identifier

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, '"}').

Issue with materialized path

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.
izbor_008

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.

FROM_UNIXTIME SQL method

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?

Update to PHP 8

Hi ๐Ÿ‘‹
Thank you for this library!

Do you plan to update to PHP 8?

Not working with Doctrine ORM 2.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.

Doctrine types deprecations

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.

Error when using DATE_FORMAT

Hello,

I'm trying to format a date like that:

->addSelect("DATE_FORMAT(date, '%d %m %Y') as date")

But I'm getting this error :
image

When I dump

image

I got this:
image

Configuration:

PHP 8.0.9
Symfony 5.3
Doctrine 2.9
Doctrine extensions 2.0

Is it normal?

Thanks

Composer require doesn't load Round.php

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.