Class SqlNameContext

java.lang.Object
org.evomaster.client.java.sql.internal.SqlNameContext

public class SqlNameContext extends Object
Given a column, we need to determinate to which table it belongs to. This is not always simple, as SQL queries can use "aliases".

This problem is further exacerbated by: 1) a SELECT can have many sub-SELECTs inside it, each one defining their own independent aliases 2) a SQL command might not have all the necessary info to infer the right table for a column. In those (valid) cases of ambiguity, we must refer to the schema. WARNING: we lowercase all names of tables and columns, as SQL is (should be?) case insensitive

  • Field Details

  • Constructor Details

    • SqlNameContext

      public SqlNameContext(net.sf.jsqlparser.statement.Statement statement)
      WARNING: should only be used in tests, to avoid each time having to provide a schema for the test data
      Parameters:
      statement - to create context for
  • Method Details

    • setSchema

      public void setSchema(DbInfoDto schema)
    • hasColumn

      public boolean hasColumn(String fullyQualifyingTableName, String columnName)
      Check if table contains a column with the given name. This is based on the DB schema. If no schema is defined, this method returns false.
    • getFullyQualifiedTableName

      public String getFullyQualifiedTableName(net.sf.jsqlparser.schema.Column column)
      Parameters:
      column - a column object
      Returns:
      the name of the table that this column belongs to