Generating valid identifiers

Emile van Sebille emile at fenx.com
Thu Jul 26 20:10:19 CEST 2012


On 7/26/2012 5:26 AM Laszlo Nagy said...
> I have a program that creates various database objects in PostgreSQL.
> There is a DOM, and for each element in the DOM, a database object is
> created (schema, table, field, index and tablespace).
>
> I do not want this program to generate very long identifiers. It would
> increase SQL parsing time, and don't look good. Let's just say that the
> limit should be 32 characters. But I also want to recognize the
> identifiers when I look at their modified/truncated names.

I had a similar problem with one customer where their legacy green 
screen app allowed only 40 characters max for the product description, 
but the marketing description lengths routinely ran out to 75 or so 
characters.  In that situation I reviewed the source marketing 
descriptions and prepped a utility to translate common longer words or 
phrases to one of a selection of shortened abbreviations. I then cycled 
through best fitting substitutions to get as close as reasonable to the 
40 character limit which generally resulted in recognizable descriptions 
in the legacy environment that matched by being directly derived from 
the longer marketing names.

YMMV,

Emile









More information about the Python-list mailing list