nodeTableName handles *tree.TableName nodes.
(ctx *Context, node *tree.TableName)
| 24 | |
| 25 | // nodeTableName handles *tree.TableName nodes. |
| 26 | func nodeTableName(ctx *Context, node *tree.TableName) (vitess.TableName, error) { |
| 27 | if node == nil { |
| 28 | return vitess.TableName{}, nil |
| 29 | } |
| 30 | var dbName, schemaName vitess.TableIdent |
| 31 | if node.ExplicitCatalog { |
| 32 | dbName = vitess.NewTableIdent(string(node.CatalogName)) |
| 33 | } |
| 34 | if node.ExplicitSchema { |
| 35 | schemaName = vitess.NewTableIdent(string(node.SchemaName)) |
| 36 | } |
| 37 | // for the information_schema schema, we treat it as a database name to make queries against it work with the engine |
| 38 | // TODO: this is a hack, we need to handle information_schema differently for doltgres, and as a true schema in each db |
| 39 | if strings.EqualFold(schemaName.String(), "information_schema") { |
| 40 | return vitess.TableName{ |
| 41 | Name: vitess.NewTableIdent(string(node.ObjectName)), |
| 42 | DbQualifier: schemaName, |
| 43 | }, nil |
| 44 | } else { |
| 45 | return vitess.TableName{ |
| 46 | Name: vitess.NewTableIdent(string(node.ObjectName)), |
| 47 | DbQualifier: dbName, |
| 48 | SchemaQualifier: schemaName, |
| 49 | }, nil |
| 50 | } |
| 51 | } |
no test coverage detected