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

How to use labels(n)[0] in where? #98

Open
beshoo opened this issue Jan 9, 2024 · 5 comments
Open

How to use labels(n)[0] in where? #98

beshoo opened this issue Jan 9, 2024 · 5 comments

Comments

@beshoo
Copy link

beshoo commented Jan 9, 2024

I have this code, but am confused about how to convert it! even ChatGPT doesn't know LOL
BTW: the documentation does not cover all aspects of this great lib, is there another doc?
Thank you

 MATCH (n)
                where (n.status=0 or n.status="0") and (n.lableb is null)  
                and (labels(n)[0]="CharactourM" or labels(n)[0]="CompanyM" )
                RETURN distinct labels(n)[0] as label,count(n) as count 
@marijnvanwezel
Copy link
Collaborator

Hi Beshoo! Unfortunately, this syntax is not yet supported, but you can use a raw expression to emulate it:

use function WikibaseSolutions\CypherDSL\node;
use function WikibaseSolutions\CypherDSL\procedure;
use function WikibaseSolutions\CypherDSL\query;
use function WikibaseSolutions\CypherDSL\raw;

require __DIR__ . '/../vendor/autoload.php';

$n = node();
$query = query()
    ->match($n)
    ->where(
        $n->property('status')->equals(0)->or($n->property('status')->equals('0'))
            ->and($n->property('lableb')->isNull())
            ->and(
                raw(procedure()::raw('labels', $n)->toQuery() . '[0]')->equals("CharactourM")
             ->or(
                raw(procedure()::raw('labels', $n)->toQuery() . '[0]')->equals("CompanyM"))))
    ->returning([
        raw(procedure()::raw('labels', $n)->toQuery() . '[0]')
            ->alias('label'),
        procedure()::raw('count', $n)
            ->alias('count')
    ], distinct: true)
    ->toQuery();

The syntax for raw queries and procedures is rather ugly. I'll see if I can make some improvements.

@beshoo
Copy link
Author

beshoo commented Jan 9, 2024

@marijnvanwezel Thank you for your reply.

However, my manager finds this raw difficult to understand, as you already said it is ugly .
even chatGpt don't like it, LOL

Can we expect any updates in the upcoming days?

@marijnvanwezel
Copy link
Collaborator

Hi @beshoo, I would not expect an update that fixes this in the coming days. The project this library was initially developed for is no longer being worked on, which put this library on the backburner as well.

I am willing to spend some time reviewing potential pull requests! :)

@beshoo
Copy link
Author

beshoo commented Jan 10, 2024

I did my best to understand the HowItWorks library, but unfortunately, shame on me, I don't think I have the skills to create a pull request for it.

However, I believe it's crucial to support the 'label' feature in this case since neo4J is all about labels! Right?

Could you please add this support to the library since you know where and how to do it?
I Do understand that you put this library on the backburner,
But , this update will make the DSL more up-to-date and beneficial for the open-source community!

I am kindly requesting an exception and a big favor for both me and the community.

Thank you so much!

@marijnvanwezel
Copy link
Collaborator

I will see if I can get some hours to work on this.

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

No branches or pull requests

2 participants