unresolvedNameToColName converts a tree.UnresolvedName to a vitess.ColName with the appropriate name qualifiers set.
(name *tree.UnresolvedName)
| 873 | |
| 874 | // unresolvedNameToColName converts a tree.UnresolvedName to a vitess.ColName with the appropriate name qualifiers set. |
| 875 | func unresolvedNameToColName(name *tree.UnresolvedName) (*vitess.ColName, error) { |
| 876 | var tableName vitess.TableName |
| 877 | switch name.NumParts { |
| 878 | case 4: |
| 879 | tableName = vitess.TableName{ |
| 880 | Name: vitess.NewTableIdent(name.Parts[1]), |
| 881 | SchemaQualifier: vitess.NewTableIdent(name.Parts[2]), |
| 882 | DbQualifier: vitess.NewTableIdent(name.Parts[3]), |
| 883 | } |
| 884 | case 3: |
| 885 | tableName = vitess.TableName{ |
| 886 | Name: vitess.NewTableIdent(name.Parts[1]), |
| 887 | SchemaQualifier: vitess.NewTableIdent(name.Parts[2]), |
| 888 | } |
| 889 | case 2: |
| 890 | tableName = vitess.TableName{ |
| 891 | Name: vitess.NewTableIdent(name.Parts[1]), |
| 892 | } |
| 893 | case 1: |
| 894 | // no table name |
| 895 | default: |
| 896 | return nil, errors.Errorf("invalid name: %s", name) |
| 897 | } |
| 898 | |
| 899 | return &vitess.ColName{ |
| 900 | Name: vitess.NewColIdent(name.Parts[0]), |
| 901 | Qualifier: tableName, |
| 902 | }, nil |
| 903 | } |
| 904 | |
| 905 | // translateConvertType translates the *vitess.ConvertType expression given to a new one, substituting type names as |
| 906 | // appropriate. An error is returned if the type named cannot be supported. |
no test coverage detected