Doctrine missing “WHERE” clause

I’m attempting to move my Behat tests from Jenkins (which builds a server each run), to Docker, so that I can add it to Travis.

I’ve run in to a little problem where the WHERE part of a query isn’t being inserted by Doctrine. The DQL output is this:

  • no fontmanager in java.library.path
  • Is it possible to have docker running inside of vmware?
  • Service ports not visible in overlay network across hosts using docker swarm mode
  • How to prevent docker containers from consuming all CPU?
  • Docker container reach outside network addresses
  • how to run docker commands inside jenkins pipeline jobs
  • SELECT v FROM \Database\Entity\SoftwareVersion v WHERE  ORDER BY v.versionMajor DESC, v.versionMinor DESC, v.versionPatch DESC, v.createdAt DESC

    As you can see, nothing between WHERE and ORDER.

    The query builder code looks like this:

     * Get the criteria array for versions
     * @param SoftwareProduct $product Required. The product to check versions for
     * @param SoftwareOperatingSystem $operatingSystem Required. The operating system you are using.
     * @param string $version Optional. Approximate or exact version to check for. Eg 2.0 Might return 2.0.2
     * @param string $order Should be ASC or DESC. Default: DESC
     * @param int|null $limit How many results you want. Leave blank for all
     * @return SoftwareVersion[]
     * @throws Exception
    public function getVersions(
        SoftwareProduct $product,
        SoftwareOperatingSystem $operatingSystem = null,
        $version = null,
        $order = 'DESC',
        $limit = null
    ) {
        if ($order != 'DESC' && $order != 'ASC') {
            throw new \DomainException("Invalid order '$order'");
        $builder = $this->getEntityManager()
            ->from('\Database\Entity\SoftwareVersion', 'v')
            ->andWhere('v.deletedAt IS NULL')
            ->andWhere($builder->expr()->lt('v.releaseDate', ':releaseDate'))
            ->setParameter('releaseDate', date('Y-m-d H:i:s'))
            ->andWhere($builder->expr()->eq('v.product', ':product'))
            ->setParameter('product', $product->getId())
        // Anonymous function for simplified code
        $equalIfExists = function ($key, $value) use ($builder) {
            if ($value !== null) {
                    ->andWhere($builder->expr()->eq("v.$key", ":$key"))
                    ->setParameter($key, $value);
        // OS
        $equalIfExists('operatingSystem', $operatingSystem);
        // Version Number
        $versionObject = $this->stringToVersion($version);
        $equalIfExists('versionMajor', $versionObject->getVersionMajor());
        $equalIfExists('versionMinor', $versionObject->getVersionMinor());
        $equalIfExists('versionPatch', $versionObject->getVersionPatch());
        // Version Meta
            ->andWhere($builder->expr()->like("v.meta", ":meta"))
            ->setParameter('meta', $versionObject->getMeta() ? "{$versionObject->getMeta()}%" : '');
            ->addOrderBy('v.versionMajor', $order)
            ->addOrderBy('v.versionMinor', $order)
            ->addOrderBy('v.versionPatch', $order)
            ->addOrderBy('v.createdAt', $order);
        $query = $builder->getQuery();
        if ($limit) {
        return $query->execute();

    I know, it looks pretty complicated, but even if we take the first few lines:

        ->from('\Mischief\Database\Entity\SoftwareVersion', 'v')
        ->andWhere('v.deletedAt IS NULL')

    It still doesn’t work.

    What’s more interesting: this code is live and functions as expected. I’ve checked the project dependencies are the same.

    The docker file for my PHP container is this:

    FROM php:7-fpm
    RUN docker-php-ext-install pdo pdo_mysql mbstring

    I can’t see any modules on live that aren’t in here.

    So where is my WHERE? 🙂

    Please ask if I can offer any more information.

  • Canonical way to checksum downloads in a Dockerfile?
  • How to give my desktop Ubuntu machine's user full permissions to a docker volume, in addition to TWO users within the docker container?
  • How to mount a directory in docker container to host
  • Run a docker hub container on bluemix without crashing (No valid host was found)
  • How to tunnel a docker X windows to a remote host?
  • Docker 1.12 Swarm Mode - Load balance tasks of the same service on single node
  • One Solution collect form web for “Doctrine missing “WHERE” clause”

        ->from('\Database\Entity\SoftwareVersion', 'v')
        ->where('v.deletedAt IS NULL')
        ->andwhere($builder->expr()->lt('v.releaseDate', ':releaseDate'))
        ->andwhere($builder->expr()->eq('v.product', ':product'))
        ->setParameter('releaseDate', date('Y-m-d H:i:s'))
        ->setParameter('product', $product->getId())
    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.