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

Add RenderNameCase.LOWER_IF_UNQUOTED and UPPER_IF_UNQUOTED #8102

Closed
lukaseder opened this issue Dec 10, 2018 · 0 comments
Closed

Add RenderNameCase.LOWER_IF_UNQUOTED and UPPER_IF_UNQUOTED #8102

lukaseder opened this issue Dec 10, 2018 · 0 comments

Comments

@lukaseder
Copy link
Member

lukaseder commented Dec 10, 2018

In #5909, we've cleanly separated the two features:

  • Quoting of names
  • Upper / lower casing of names

No new features were introduced, just the separation was implemented. However, the behaviour of RenderNameCase.LOWER and UPPER is not so terribly useful when we specify RenderQuotedNames.ALWAYS, as it might lead to wrong SQL (such as referencing "INFORMATION_SCHEMA" on PostgreSQL, or "information_schema" on H2).

This is why we need additional LOWER_IF_UNQUOTED and UPPER_IF_UNQUOTED flags in RenderNameCase, which modify names only if they're not quoted. (i.e. DSL.unquotedName()). The following test shows the expected behaviour:

    @Test
    public void testRenderNameCaseOfQuotedAndUnquotedNames() {
        Name name = name(quotedName("Quoted"), unquotedName("Unquoted"));

        assertEquals("`Quoted`.Unquoted", r_ref().render(name));

        create.settings().setRenderNameCase(RenderNameCase.LOWER);
        assertEquals("`quoted`.unquoted", r_ref().render(name));

        create.settings().setRenderNameCase(RenderNameCase.LOWER_IF_UNQUOTED);
        assertEquals("`Quoted`.unquoted", r_ref().render(name));

        create.settings().setRenderNameCase(RenderNameCase.UPPER);
        assertEquals("`QUOTED`.UNQUOTED", r_ref().render(name));

        create.settings().setRenderNameCase(RenderNameCase.UPPER_IF_UNQUOTED);
        assertEquals("`Quoted`.UNQUOTED", r_ref().render(name));
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant