in

The ORM Foundation

Get the facts!

PascalCase column generation not working in generated SQL; customizing column name output

Last post Wed, May 23 2012 11:30 by Tyler Young. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • Mon, May 14 2012 18:45

    • Tyler Young
    • Top 10 Contributor
      Male
    • Joined on Thu, Aug 27 2009
    • South Jordan, Utah, USA
    • Posts 49

    PascalCase column generation not working in generated SQL; customizing column name output

    I went into "ORM Model Browser" -> "Name Generation Settings" -> "Name Generation Defaults" -> "Relational Names" -> "Column Specific" -> "CasingOption". On the Relational View it gives the correct casing, but in the generated SQL it's still coming through as camelCase.

    On a related side note, I'm going through and customizing the output to give "VARCHAR" rather than "CHARACTER VARYING", etc. One of the customizations I'd like is enclosing the column name in [brackets] for cases where column names are reserved words. For example, [Order] or [Right].

    To make changes to the column name, I've tried DDILtoSQLServer.xslt and DILSupportFunctions.xslt, but neither of them are giving the desired [result]. Are there other places I should be looking, or have I just not found the right spot yet?

    I realize that the changes I'm making will likely break generation for Oracle, DB2, and MySQL on this machine. For the scope of this project, that's acceptable.

    Filed under:
  • Mon, May 14 2012 22:40 In reply to

    Re: PascalCase column generation not working in generated SQL; customizing column name output

    Hi Tyler,

    This seems to be working fine for me. Have you saved the file or explicitly executed 'Run Custom Tool' on the .orm file to make sure the generated SQL is up to date? The only thing this isn't applying to is custom column names, which aren't touched by the name generator.

    The sql key words are already quoted in 'makeValidIdentifier' in DILSupportFunctions.xlst. If you're set on using square-bracket delimiters instead of "" then you could modify it there.

    Changing the data type names is best done in the DBMS-specific XSLT overrides (DDILtoSqlServer.xslt) using the ForDataType mode applied to @type attributes.

    -Matt

  • Wed, May 16 2012 14:04 In reply to

    • Tyler Young
    • Top 10 Contributor
      Male
    • Joined on Thu, Aug 27 2009
    • South Jordan, Utah, USA
    • Posts 49

    Re: PascalCase column generation not working in generated SQL; customizing column name output

    Thanks for the quick response, Matt! The data type changes were easy enough to modify in DDILtoSqlServer.xslt. Names are a bit trickier. I've been hitting "Run Custom Tool" explicitly. Maybe I'm going through the wrong file? The one I'm editing is C:\Program Files (x86)\Common Files\Neumont\DIL\Transforms\DILSupportFunctions.xslt. I changed the makeValidIdentifier to:

    function makeValidIdentifier(name, maxLength) {return "foo" + name;}

    but it hasn't affected the output.

  • Wed, May 16 2012 19:08 In reply to

    Re: PascalCase column generation not working in generated SQL; customizing column name output

    The custom tool is smart enough to reload directly loaded transform files such as DDILtoSqlServer.xslt on change, but AFAIK it doesn't look for imported transform forms, so you'll need to restart VS to pick up a makeValidIdentifier change.

    You can do quite a bit with names by adding abbreviations to the name generation settings. Abbreviations apply to the word based as determined by casing, so GovernmentAgent can be mapped to govAgt with one abbreviation for 'government' and one for 'agent'.

    The last two public releases also support customizing the column names as a final resort.

    -Matt

  • Fri, May 18 2012 12:05 In reply to

    • Tyler Young
    • Top 10 Contributor
      Male
    • Joined on Thu, Aug 27 2009
    • South Jordan, Utah, USA
    • Posts 49

    Re: PascalCase column generation not working in generated SQL; customizing column name output

    Ah yes, I did need to restart VS. Thanks! But it's interesting... changes to makeValidIdentifier are only showing up in a couple of areas. I think I'm going to experiment with my computer at home and see if it's the same there or if my work computer is having problems.

    Where are the abbreviation settings kept? After a bit of poking around, they remain elusive.

    Thanks, Matt!

  • Fri, May 18 2012 14:05 In reply to

    Re: PascalCase column generation not working in generated SQL; customizing column name output

    The abbreviations settings are in a dialog available through the 'Abbreviations' property on any of the Name Generation Settings child nodes (Name Generation Defaults, Relational Names, Table Specific, Column Specific). You can modify object type names (but not eliminate them) or any other phrase, including replacing the phrase with empty text to eliminate it.

    These are called abbrevations, but are really arbitrary replacements that are generally used to abbreviate. You can put longer phrases in here if you like.

    -Matt

  • Wed, May 23 2012 11:30 In reply to

    • Tyler Young
    • Top 10 Contributor
      Male
    • Joined on Thu, Aug 27 2009
    • South Jordan, Utah, USA
    • Posts 49

    Re: PascalCase column generation not working in generated SQL; customizing column name output

    I love the "abbreviations" setting. That's made my day!
Page 1 of 1 (7 items)
© 2008-2024 ------- Terms of Service