Parse::Dia::SQL::Utils - Helper class for Parse::Dia::SQL.


  Not to be used directly.


Utility functions for Parse::Dia::SQL.


Define primary key column names and types for automatic generation of primary keys in tables that need them, but do not have them defined.


The constructor. No arguments.



Given a node with dia:attribute nodes inside it, go through the dia:attribute nodes with attribute "name='...'" and return the string values

@infosToGet is an array of strings, where the first character is the data type to get, and the remaining characters are the name to parse for. first character legal values are:

   a = alpha
   9 = numeric
   b = boolean

example: aname, 9dollars, bkillOrNot


If it looks like <thingy><dia:string>value</dia:string></thingy> then we will get the 'value' part out given the node is 'thingy'.


Given an object, node name, attribute name, attribute value, and value to retrieve type, find the info and return it.


Given an object, node name, attribute name, and attribute value, return the node that has all these things.


Transform case for name comparisons to that of the database; leave unchanged if -C (preserve case) is in effect. Only sybase is known to be case sensitive.


Return value part of <dia:enum val="value"></thingy>.


Return value part of <thingy><dia:boolean val="value"></thingy>.


Look at a multiplicity descriptor and classify it as 'one' (1, or 1..1), 'zone' (0..1), 'many' (n..m, n..*, where n > 1, m >= n) and 'zmany' (0..n, 0..*, where n > 1)


Generate a list of attributes from a comma-separated list of names by looking up a class' attribute table.


Generate a comma-separated list of attribute names from a list of attributes.


Check that a list of primary key attributes has types corresponding to the types in a list of foreign key attributes


Check that a list of primary key attributes has types corresponding to the types in a list of foreign key attributes.

Returns base type of some DMBS specific types (eg in PostgreSQL serial is integer).

AFF note: This is better implemented in each sql formatter class.


Generate a longer name from parts supplied. Except for the first part, the first letter of each part is capitalised. If lcFirstWord is set, then any initial string of capitals in the first part is made lower case; otherwise the first part is left unchanged.

Dies if $self->{db} is not set.

The @parts_org values are save for "Desperation time" :)


PSuda: Name scrambling helper function, for code which auto-generates names. Takes one arg, which is string to use for md5 hashing. This returns names which consist entirely of underscores and alphanumeric characters, and starts with one or more alpha characters.


Get a name to mangle and mangle it to the length specified -- avoid too much manglification if the name is only slightly long, but mangle lots if it's a lot longer than the specified length.


For -p - add a default primary key to a parsed table definition

TODO : Add a meaningful return value.


For -f - add missing parts of a default foreign key to a parsed table definition.