---
name: "Parse::Dia::SQL::Utils"
section: "3pm"
platform: "linux"
package: "libparse-dia-sql-perl"
version: "0.31-2"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/Parse::Dia::SQL::Utils"
---

# Parse::Dia::SQL::Utils(3pm)

Helper class for Parse::Dia::SQL.

## NAME

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

## SYNOPSIS

```
  Not to be used directly.
```

## DESCRIPTION

Utility functions for Parse::Dia::SQL.

### set\_default\_pk

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

### new

The constructor.  No arguments.

### new

### get\_node\_attribute\_values

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

### get\_string\_from\_node

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

### get\_value\_from\_object

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

### get\_node\_from\_object

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

### name\_case

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.

### get\_num\_from\_node

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

### get\_bool\_from\_node

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

### classify\_multiplicity

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)

### attlist\_from\_names

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

### names\_from\_attlist

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

### check\_att\_list\_types

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

### get\_base\_type

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.

### make\_name

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" :)

### name\_scramble

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.

### mangle\_name

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.

### add\_default\_pk

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

TODO : Add a meaningful return value.

### add\_default\_fk

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