parser
parser copied to clipboard
Is it possible to extract table and its related columns from sql query?
Question
For example, If query is
SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
FROM Orders
INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID;
I need something like below,
{
"tableName":"Orders",
"columns":[
"OrderID",
"OrderData",
"CustomerID"
]
}
And
{
"tableName":"Customers",
"columns":[
"CustomerName",
"CustomerID"
]
}
I can extract table names and column names separately, but is there anyway to extract table and its related columns? or Is it possible to extract table and its related columns in a single struct?
I think this is a good idea, but there seems no mehod, you can get table name from *ast.ColumnName.Table.String()
you need a visitor to do that