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

Renderer alwaysEscapeNames ignored when withPrettyPrint is true #522

Closed
ikwattro opened this issue Dec 18, 2022 · 2 comments
Closed

Renderer alwaysEscapeNames ignored when withPrettyPrint is true #522

ikwattro opened this issue Dec 18, 2022 · 2 comments

Comments

@ikwattro
Copy link
Contributor

ikwattro commented Dec 18, 2022

Version: 2022.8.1

Given the following statement

var start = Cypher.node("Person").named("person");
var statement = Cypher.match(start)
        .returning(start.property("name"), start.property("born"))
        .limit(10)
        .build();

The following configuration for the Renderer produces correctly escaped label names

var config = Configuration.newConfig().alwaysEscapeNames(true).build();

However, once the configuration is combined with withPrettyPrint having true, the label names are not escaped.

var config = Configuration.newConfig().alwaysEscapeNames(true).withPrettyPrint(true).build();

Reproducable failing test :

    @Test
    void fetch_escaping_with_pretty_print() {
        var start = Cypher.node("Person").named("person");
        var statement = Cypher.match(start)
                .returning(start.property("name"), start.property("born"))
                .limit(10)
                .build();

        var config = Configuration.newConfig().alwaysEscapeNames(true).withPrettyPrint(true).build();
        var generatedQuery = Renderer.getRenderer(config).render(statement);
        Assertions.assertTrue(generatedQuery.contains("MATCH (person:`Person`)"));
    }

I see from the code it is intended probably ?

public Builder withPrettyPrint(boolean prettyPrint) {
			this.prettyPrint = prettyPrint;
			if (this.prettyPrint) {
				return this.alwaysEscapeNames(false);
			}
			return this;
		}

However you can bypass it if you switch the method calls order

var configuration = Configuration.newConfig().withPrettyPrint(true).alwaysEscapeNames(true).build();
@ikwattro ikwattro changed the title Rendered alwaysEscapeNames ignored when withPrettyPrint is true Renderer alwaysEscapeNames ignored when withPrettyPrint is true Dec 18, 2022
@michael-simons
Copy link
Collaborator

That is on purpose.

@michael-simons
Copy link
Collaborator

Added this to the docs.

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