Java Code Examples for net.sf.jsqlparser.schema.Column#getTable()
The following examples show how to use
net.sf.jsqlparser.schema.Column#getTable() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CloudSpannerResultSetMetaData.java From spanner-jdbc with MIT License | 6 votes |
@Override public int isNullable(int column) throws SQLException { Column col = getColumn(column); if (col != null && col.getTable() != null) { String schema = Strings.isNullOrEmpty(col.getTable().getSchemaName()) ? "" : CloudSpannerDriver.unquoteIdentifier(col.getTable().getSchemaName()); String tableName = CloudSpannerDriver.unquoteIdentifier(col.getTable().getName()); String colName = CloudSpannerDriver.unquoteIdentifier(col.getColumnName()); try (java.sql.ResultSet rs = statement.getConnection().getMetaData().getColumns("", schema, tableName, colName)) { if (rs.next()) { return rs.getInt("NULLABLE"); } } } return columnNullableUnknown; }
Example 2
Source File: JSQLParserAdapter.java From ddal with Apache License 2.0 | 6 votes |
private void routeTable(TableWrapper tab, Column column, Object sdValue) { if (tab == null) {// return; } if (tab == AMBIGUOUS_TABLE) { throw new RuntimeException("Shard value '" + column.toString() + "' in where clause is ambiguous. Sql is [" + sql + "]"); } ShardRouteInfo routeInfo = getRouteInfo(tab, sdValue); // 当没有设置别名,但分表字段使用了表前缀时,别前缀需要根据路由结果进行重写; // 这里之所有没有采用将table取名的方式是因为update/delete/insert不全支持别名; // 由于select都是支持别名的,所有都会被添加别名,因此不会执行下面的操作; Table columnTable = column.getTable(); if (tab.getAlias() == null && columnTable != null && columnTable.getName() != null && columnTable.getName().length() > 0) { if (columnTable.getSchemaName() != null) { columnTable.setSchemaName(routeInfo.getScName()); } columnTable.setName(routeInfo.getTbName()); } route0(tab, routeInfo); }
Example 3
Source File: OnVisitorMatchLookupBuilder.java From sql-to-mongo-db-query-converter with Apache License 2.0 | 6 votes |
@Override public void visit(Column column) { if(SqlUtils.isColumn(column)) { String columnName; if(column.getTable() != null) { columnName = SqlUtils.getColumnNameFromColumn(column); } else { columnName = column.getColumnName(); } if(!SqlUtils.isTableAliasOfColumn(column, joinAliasTable) ) { if(column.getTable() == null || SqlUtils.isTableAliasOfColumn(column, baseAliasTable)) {//we know let var don't have table inside column.setColumnName("$$" + columnName.replace(".", "_").toLowerCase()); } else { column.setColumnName("$$" + column.getName(false).replace(".", "_").toLowerCase()); } column.setTable(null); } else { column.setTable(null); column.setColumnName("$" + columnName); } } }
Example 4
Source File: CTEToNestedQueryConverter.java From quetzal with Eclipse Public License 2.0 | 6 votes |
@Override public void visit(Column tableColumn) { clear(); boolean prevIsTopLevel = isTopLevel; isTopLevel = false; if (tableColumn.getTable()!=null && tableColumn.getTable().getName()!=null) { if (tableColumn.getTable().getName().equalsIgnoreCase(leftTable.getAlias()!=null? leftTable.getAlias().getName(): leftTable.getName())) { leftTableFound = true; } if (tableColumn.getTable().getName().equalsIgnoreCase(rightTable.getAlias()!=null? rightTable.getAlias().getName(): rightTable.getName())) { rightTableFound = true; } } isTopLevel = prevIsTopLevel; defaultTopLevelProcessing(tableColumn); }
Example 5
Source File: CloudSpannerResultSetMetaData.java From spanner-jdbc with MIT License | 5 votes |
@Override public int getPrecision(int column) throws SQLException { int colType = getColumnType(column); switch (colType) { case Types.BOOLEAN: return 1; case Types.DATE: return 10; case Types.DOUBLE: return 14; case Types.BIGINT: return 10; case Types.TIMESTAMP: return 24; default: // Not fixed size, try to get it from INFORMATION_SCHEMA } Column col = getColumn(column); if (col != null && col.getTable() != null) { String schema = Strings.isNullOrEmpty(col.getTable().getSchemaName()) ? "" : CloudSpannerDriver.unquoteIdentifier(col.getTable().getSchemaName()); String tableName = CloudSpannerDriver.unquoteIdentifier(col.getTable().getName()); String colName = CloudSpannerDriver.unquoteIdentifier(col.getColumnName()); try (java.sql.ResultSet rs = statement.getConnection().getMetaData().getColumns("", schema, tableName, colName)) { if (rs.next()) { return rs.getInt("COLUMN_SIZE"); } } } return 0; }
Example 6
Source File: CloudSpannerResultSetMetaData.java From spanner-jdbc with MIT License | 5 votes |
@Override public String getTableName(int column) throws SQLException { Column col = getColumn(column); if (col != null && col.getTable() != null) return col.getTable().getName(); return ""; }
Example 7
Source File: CloudSpannerResultSetMetaData.java From spanner-jdbc with MIT License | 5 votes |
@Override public boolean isReadOnly(int column) throws SQLException { Column col = getColumn(column); if (col == null || col.getTable() == null) return true; // Primary key columns are only insertable and never updatable, all // other columns are insertable and updatable. This however still means // that a primary key column is writable. return false; }
Example 8
Source File: UsedColumnExtractorVisitor.java From evosql with Apache License 2.0 | 5 votes |
@Override public void visit(Column arg0) { String tableName = null; if (arg0.getTable() != null) { if (arg0.getTable().getAlias() != null) tableName = arg0.getTable().getAlias().getName(); else tableName = arg0.getTable().getName(); } // If it is outer select, don't add, otherwise do add if (!(currentState.isOuterState && currentState.phase == SelectPhase.SELECT)) { addUsedColumn(arg0.getColumnName(), tableName); } }
Example 9
Source File: SqlSecurerVisitor.java From evosql with Apache License 2.0 | 5 votes |
@Override public void visit(Column arg0) { Table table = arg0.getTable(); if (table != null) { table.accept(this); } arg0.setColumnName(secureName(arg0.getColumnName())); }
Example 10
Source File: CTEToNestedQueryConverter.java From quetzal with Eclipse Public License 2.0 | 5 votes |
private Expression getExpression(SelectItem item, Table table) { SelectExpressionItem rightSelectItem = (SelectExpressionItem) item; Expression rightExp = rightSelectItem.getExpression(); if (rightExp instanceof Column) { Column c = (Column) rightExp; if (c.getTable() == null) { c.setTable(table); } } return rightExp; }
Example 11
Source File: CloudSpannerResultSetMetaData.java From spanner-jdbc with MIT License | 4 votes |
@Override public boolean isSearchable(int column) throws SQLException { Column col = getColumn(column); return col != null && col.getTable() != null; }
Example 12
Source File: SqlToCqlTranslator.java From cassandra-jdbc-driver with Apache License 2.0 | 4 votes |
public void visit(Column tableColumn) { if (tableColumn.getTable() != null) { tableColumn.setTable(null); } }
Example 13
Source File: TableVisitor.java From DDF with Apache License 2.0 | 4 votes |
public void visit(Column tableColumn) throws Exception { if (tableColumn.getTable() != null) { tableColumn.getTable().accept(this); } }