-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding ILIKE support #33
Comments
Released in v1.1 |
public function restFindBy(array $criteria)
{
$queryBuilder = $this->createQueryBuilder('shipping_segment');
$queryBuilder->andWhere('shipping_segment.name ILIKE :filter OR shipping_segment.description ILIKE :filter');
$queryBuilder->setParameter('filter', '%'.$criteria['filter'].'%');
$pagerfanta = new Pagerfanta(new DoctrineORMAdapter($queryBuilder, false, false));
return $pagerfanta->getCurrentPageResults();
} error: {
"message": "[Syntax Error] line 0, col 102: Error: Expected =, <, <=, <>, >, >=, !=, got 'ILIKE'",
"class": "Doctrine\\ORM\\Query\\QueryException",
"trace": [
{
"namespace": "",
"short_class": "",
"class": "",
"type": "",
"function": "",
"file": "S:\\OSPanel\\domains\\saas-shipping-backend.loc\\vendor\\doctrine\\orm\\lib\\Doctrine\\ORM\\Query\\QueryException.php",
"line": 54,
"args": []
},
{
"namespace": "Doctrine\\ORM\\Query",
"short_class": "QueryException",
"class": "Doctrine\\ORM\\Query\\QueryException",
"type": "::",
"function": "syntaxError",
"file": "S:\\OSPanel\\domains\\saas-shipping-backend.loc\\vendor\\doctrine\\orm\\lib\\Doctrine\\ORM\\Query\\Parser.php",
"line": 456,
"args": [
[
"string",
"line 0, col 102: Error: Expected =, <, <=, <>, >, >=, !=, got 'ILIKE'"
],
[
"object",
"Doctrine\\ORM\\Query\\QueryException"
]
]
}
]
} but |
Which Doctrine version do you use @Gemorroj ? |
Did you may try to trick Doctrine to parse with construction like |
@martin-georgiev if add |
Can you upload your Doctrine configuration and entity mapping to debug? |
this is Symfony 4 project
ShippingSegment.php <?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Nelmio\ApiDocBundle\Annotation\Model;
use Swagger\Annotations as SWG;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Table(schema="shipping", uniqueConstraints={
* @ORM\UniqueConstraint(columns={"user_id", "name"})
* })
* @ORM\HasLifecycleCallbacks
* @ORM\Entity(repositoryClass="App\Repository\ShippingSegmentRepository")
*/
class ShippingSegment
{
/**
* @var int
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
* @ORM\Column(type="integer", nullable=false, options={"unsigned": true})
* @Groups({"default"})
* @SWG\Property(description="Shipping segment id")
*/
private $id;
/**
* @var string
* @SWG\Property(description="Name")
* @ORM\Column(type="string", length=255)
* @Assert\Length(max=255)
* @Assert\NotNull
* @Groups({"default"})
*/
private $name;
/**
* @var string|null
* @SWG\Property(description="Description")
* @ORM\Column(type="string", length=5000, nullable=true)
* @Assert\Length(max=5000)
* @Groups({"default"})
*/
private $description; |
schema CREATE TABLE shipping.shipping_segment (id SERIAL NOT NULL, user_id INT NOT NULL, created_at TIMESTAMP(0) WITH TIME ZONE NOT NULL, updated_at TIMESTAMP(0) WITH TIME ZONE DEFAULT NULL, name VARCHAR(255) NOT NULL, description VARCHAR(5000) DEFAULT NULL, PRIMARY KEY(id)); |
dump DQL: SELECT shipping_segment FROM App\Entity\ShippingSegment shipping_segment WHERE ((shipping_segment.name ILIKE :filter) OR (shipping_segment.description LIKE :filter)) AND shipping_segment.user = :shipping_segment_user ORDER BY shipping_segment.id desc |
@Gemorroj Could you please try ILIKE(shipping_segment.name,:filter) = TRUE ? |
@llaakkkk Yes, it works =) |
Hello Martin,
I use your package in my project, and I want to say BIG thanks for your work. Your package is really helpful.
And I want to suggest to you to add ILIKE function support.
I can do it by myself, but it would be great if you will help me with understanding what is inside your package.
The text was updated successfully, but these errors were encountered: