Class TAttributeNode

Object
gudusoft.gsqlparser.compiler.TSymbol
gudusoft.gsqlparser.TAttributeNode

public class TAttributeNode extends gudusoft.gsqlparser.compiler.TSymbol
TAttributeNode 类似 column,但含义更广泛。用来表示 SQL 语句中 table 包含的字段(table 或许用 relation 更准确)。 这里的 table 可以是数据库的基本表,也可以是 from clause 中出现的子查询,或者是 CTE。 GSP 会把 SQL 语句中出现的每个 table 都生成对应的 TAttributeNode 列表,表示该 table 可以在 SQL 中被使用的字段。 例如:一般 table select column1 from table1 GSP 会在 SQLEnv 中查找 table1 的定义,如果找到(column1,column2,column3), 则 table 会创建三个对应的 TAttributeNode。 用户可以通过 TTable.getAttributes() 来获取。 如果SQLEnv 中没有查找 table1 的定义,则创建一个 star column TAttributeNode, 形如 table1.* 例如:子查询 select column1 from (select c1,c2 from table1) t1 针对上例中的 t1 子查询, GSP 会创建两个 TAttributeNode,对应 t1.c1, t1.c2 针对其他类型的 table, 也做类似处理。为 SQL 中的每个 table 准备好 TAttributeNode 列表, 在接下来的分析中,SQL 语句中出现的 column 引用都应该能找到对应的来源表和 TAttributeNode 相关的属性 getName(), 字段名,不带前缀。 getTable_ref(), 该字段对应的 table,每个在 SQL 语句中出现的 table 都有对应的 TTable 对象。 getSqlColumn(), 如果在 SQLEnv 中找到该 table 的定义,这个方法返回数据库中定义的字段、 getSubLevelResultColumn(), 如果 table 类型为子查询,该方法返回子查询 select list 中的 TResultColumn 对象,为该字段的数据来源。 或者是 values() 中的 result column。