luxifer / doctrine-functions

📚 Set of DQL Function for MySQL
http://luxifer.github.io/doctrine-functions/
MIT License
88 stars 14 forks source link

SQLite alternative? #23

Open soullivaneuh opened 7 years ago

soullivaneuh commented 7 years ago

SQLite is frequently used instead of MySQL for unit testing.

But some functions differ.

Would you be interested by Pull Requests for SQLite alternatives?

This is a quite easy implement, for example with YEAR:

public function getSql(SqlWalker $sqlWalker)
{
    if ($sqlWalker->getConnection()->getDriver() instanceof AbstractSQLiteDriver) {
        return "DATE('%Y', {$this->dateExpression->dispatch($sqlWalker)})";
    }

    return 'YEAR('.$this->dateExpression->dispatch($sqlWalker).')';
}

What do you think?

luxifer commented 7 years ago

Yes!!!! If the result of the different function are equal, it's OK for me

soullivaneuh commented 7 years ago

@luxifer I think the tests should be rethink in this case, to test the result of a query on real databases, right?

luxifer commented 7 years ago

I don't think it's useful to test that as it will introduce a lot of overhead in the test suite. As long as the MySQL and SQlite doc specify the same value for the return, it's OK for me