(item)
| 78 | # We need to do some massaging of the names because postgres is case- |
| 79 | # insensitive and '"Foo"' is not the same table as 'Foo' (while 'foo' is) |
| 80 | def parse_identifier(item): |
| 81 | name = item.get_real_name() |
| 82 | schema_name = item.get_parent_name() |
| 83 | alias = item.get_alias() |
| 84 | if not name: |
| 85 | schema_name = None |
| 86 | name = item.get_name() |
| 87 | alias = alias or name |
| 88 | schema_quoted = schema_name and item.value[0] == '"' |
| 89 | if schema_name and not schema_quoted: |
| 90 | schema_name = schema_name.lower() |
| 91 | quote_count = item.value.count('"') |
| 92 | name_quoted = quote_count > 2 or (quote_count and not schema_quoted) |
| 93 | alias_quoted = alias and item.value[-1] == '"' |
| 94 | if alias_quoted or name_quoted and not alias and name.islower(): |
| 95 | alias = '"' + (alias or name) + '"' |
| 96 | if name and not name_quoted and not name.islower(): |
| 97 | if not alias: |
| 98 | alias = name |
| 99 | name = name.lower() |
| 100 | return schema_name, name, alias |
| 101 | |
| 102 | try: |
| 103 | for item in token_stream: |
no outgoing calls
no test coverage detected