Skip to content
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

🐛 Fix FullTextSearch if property is null #452

Open
wants to merge 1 commit into
base: 2.x
Choose a base branch
from

Conversation

elyanory
Copy link

@elyanory elyanory commented Dec 2, 2024

Hello !

I'm currently using sulu 2.5.22 in production which uses your bundle. When I try to do a fullTextSearch on a :

$queryBuilder->andWhere(
    $this->qomFactory->fullTextSearch(
        selectorName: 'node',
        propertyName: null,
        fullTextSearchExpression: $filters['search_term']
    )
);

This doesn't work. However, when I look at the documentation, we can set the propertyName to null to search the entire node, but this doesn't work because https://github.com/jackalope/jackalope-doctrine-dbal/blob/2.x/src/Jackalope/Transport/DoctrineDBAL/Query/QOMWalker.php#L827 doesn't accept a null property, or at least it doesn't work with MySQL.

Here's a fix that works for me. Don't hesitate to send me feedback. I haven't taken the time to add the tests yet.

Copy link
Member

@dbu dbu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for looking into this! it looks plausible and seems to make sense.

to be sure the functionality works, and to double-check behaviour with jackrabbit, could you add a test case to https://github.com/phpcr/phpcr-api-tests ? (as this is phpcr spec behaviour, the functional test is enough, i don't see need for an additional unit test in this repository)

it should be failing with this repo but hopefully works with jackrabbit already, and would then be fixed by this merge request.

@@ -841,6 +851,38 @@ private function sqlXpathExtractValue(string $alias, string $property, string $c
throw new NotImplementedException(sprintf("Xpath evaluations cannot be executed with '%s' yet.", $this->platform->getName()));
}

private function sqlXpathExtractValueWithNullProperty(string $alias, string $column = 'props'): string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it make sense to have a parameter with default value for $column? if i understand correctly, this parameter is never changed, so we should use 'props' directly - or set up a constant in the class.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbu I think you're right, we could remove $column. When I look at the method above, it's hard-coded (

private function sqlXpathExtractNumValue(string $alias, string $property): string
). I can do the same thing here. But what impact will that have? It's BC, isn't it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the joy of private methods is that we only need to validate in this class. if nothing in this class passes the 3rd parameter, removing the parameter is backwards compatible.
if it really is unused, it was either used in the past and then the code changed but nobody noticed its not needed, or it was some future-feature that did not happen. as its a private method, we can just add it back in should the need arise.

for the new method, it certainly is not an issue to remove it, because you only add it right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants