Convert the specified column type to a SQL string.
 @override
769620
def type_to_sql(type, limit = nil, precision = nil, scale = nil)
      return super unless NO_LIMIT_TYPES.include?(t = type.to_s.downcase.to_sym)

      native_type = NATIVE_DATABASE_TYPES[t]
      native_type.is_a?(Hash) ? native_type[:name] : native_type
    end
827989
function columnsToSQL(columns) {
    return columns
        .map(column => {
            let str = exprToSQL(column.expr);

            if (column.as !== null) {
                str += ' AS ';
                if (column.as.match(/^[a-z_][0-9a-z_]*$/i)) str += identifierToSql(column.as);
                else str += '"' + column.as + '"';
            }

            return str;
        })
        .join(', ');
}
615228
def full_datatype_to_mysql(d: str) -> str:
    """"""
    d = d.upper()
    (s, length) = split_long_sqltype(d)
    if d in ["VARCHAR(MAX)", "NVARCHAR(MAX)"]:
        # http://wiki.ispirer.com/sqlways/mysql/data-types/longtext
        return "LONGTEXT"
    elif d in ["VARBINARY(MAX)"] or s in ["IMAGE"]:
        # http://wiki.ispirer.com/sqlways/mysql/data-types/varbinary
        return "LONGBLOB"
    else:
        return d
1255663
function serializeMember(value, columnType) {
    
    // Start by checking if the specified column type is valid
    if (!isColumnTypeValid(columnType)) {
        throw new Error('Column type ' + columnType + ' is not supported');
    }

    // Now check if the specified value can be stored in a column of type columnType
    if (!isJSValueCompatibleWithColumnType(value, columnType)) {
        throw new Error('Converting value ' + JSON.stringify(value) + ' of type ' + typeof value + ' to type ' + columnType + ' is not supported.');
    }

    // If we are here, it means we are good to proceed with serialization
    
    var sqliteType = getSqliteType(columnType),
        serializedValue;
    
    switch (sqliteType) {
        case "TEXT":
            serializedValue = typeConverter.convertToText(value);
            break;
        case "INTEGER":
            serializedValue = typeConverter.convertToInteger(value);
            break;
        case "REAL":
            serializedValue = typeConverter.convertToReal(value);
            break;
        default:
            throw new Error('Column type ' + columnType + ' is not supported');
    }
    
    return serializedValue;
}
688377
private static CsvSchema.ColumnType convertType(String fieldName, TypeInformation<?> info) {
		if (STRING_TYPES.contains(info)) {
			return CsvSchema.ColumnType.STRING;
		} else if (NUMBER_TYPES.contains(info)) {
			return CsvSchema.ColumnType.NUMBER;
		} else if (BOOLEAN_TYPES.contains(info)) {
			return CsvSchema.ColumnType.BOOLEAN;
		} else if (info instanceof ObjectArrayTypeInfo) {
			validateNestedField(fieldName, ((ObjectArrayTypeInfo) info).getComponentInfo());
			return CsvSchema.ColumnType.ARRAY;
		} else if (info instanceof BasicArrayTypeInfo) {
			validateNestedField(fieldName, ((BasicArrayTypeInfo) info).getComponentInfo());
			return CsvSchema.ColumnType.ARRAY;
		} else if (info instanceof RowTypeInfo) {
			final TypeInformation<?>[] types = ((RowTypeInfo) info).getFieldTypes();
			for (TypeInformation<?> type : types) {
				validateNestedField(fieldName, type);
			}
			return CsvSchema.ColumnType.ARRAY;
		} else if (info instanceof PrimitiveArrayTypeInfo &&
				((PrimitiveArrayTypeInfo) info).getComponentType() == Types.BYTE) {
			return CsvSchema.ColumnType.STRING;
		} else {
			throw new IllegalArgumentException(
				"Unsupported type information '" + info.toString() + "' for field '" + fieldName + "'.");
		}
	}
91012
public static int getColumnType (Connection conn, String table,
                                     String column)
        throws SQLException
    {
        ResultSet rs = getColumnMetaData(conn, table, column);
        try {
            return rs.getInt("DATA_TYPE");
        } finally {
            rs.close();
        }
    }
368616
public static String convertJavaClassToSqlType(String simpleClassName) throws SQLException {
        if ("String".equals(simpleClassName) == true) {
            return "VARCHAR";
        }

        throw new SQLException(String.format("Could not convert java class %s", simpleClassName));
    }
581945
public static Object stringToSqlValue(String value, int sqlType, boolean isRequired, boolean isEmptyStringNulled) {
        // 设置变量
        String sourceValue = value;
        if (SqlUtils.isTextType(sqlType)) {
            if ((sourceValue == null) || (true == StringUtils.isEmpty(sourceValue) && isEmptyStringNulled)) {
                return isRequired ? REQUIRED_FIELD_NULL_SUBSTITUTE : null;
            } else {
                return sourceValue;
            }
        } else {
            if (StringUtils.isEmpty(sourceValue)) {
                return isEmptyStringNulled ? null : sourceValue;// oracle的返回null，保持兼容
            } else {
                Class<?> requiredType = sqlTypeToJavaTypeMap.get(sqlType);
                if (requiredType == null) {
                    throw new IllegalArgumentException("unknow java.sql.Types - " + sqlType);
                } else if (requiredType.equals(String.class)) {
                    return sourceValue;
                } else if (true == isNumeric(sqlType)) {
                    return convertUtilsBean.convert(sourceValue.trim(), requiredType);
                } else {
                    return convertUtilsBean.convert(sourceValue, requiredType);
                }
            }
        }
    }
858269
function Column(options, index, statementParameters, resultVersion)
{
  var name     = options.name;
  var nullable = options.nullable;
  var scale    = options.scale;
  var type     = options.type;

  /**
   * Returns the name of this column.
   *
   * @return {String}
   */
  this.getName = function()
  {
    return name;
  };

  /**
   * Returns the index of this column.
   *
   * @return {Number}
   */
  this.getIndex = function()
  {
    return index;
  };

  /**
   * Returns the id of this column.
   *
   * @return {Number}
   */
  this.getId = function()
  {
    // use the index as the id for now
    return index;
  };

  /**
   * Determines if this column is nullable.
   *
   * @returns {Boolean}
   */
  this.isNullable = function()
  {
    return nullable;
  };

  /**
   * Returns the scale associated with this column.
   *
   * @returns {Number}
   */
  this.getScale = function()
  {
    return scale;
  };

  /**
   * Returns the type associated with this column.
   *
   * @returns {String}
   */
  this.getType = function()
  {
    return type;
  };

  // add methods that make it easy to check if the column is of a specific type
  this.isString       = createFnIsColumnOfType(type, SqlTypes.isString, SqlTypes);
  this.isBinary       = createFnIsColumnOfType(type, SqlTypes.isBinary, SqlTypes);
  this.isNumber       = createFnIsColumnOfType(type, SqlTypes.isNumber, SqlTypes);
  this.isBoolean      = createFnIsColumnOfType(type, SqlTypes.isBoolean, SqlTypes);
  this.isDate         = createFnIsColumnOfType(type, SqlTypes.isDate, SqlTypes);
  this.isTime         = createFnIsColumnOfType(type, SqlTypes.isTime, SqlTypes);
  this.isTimestamp    = createFnIsColumnOfType(type, SqlTypes.isTimestamp, SqlTypes);
  this.isTimestampLtz = createFnIsColumnOfType(type, SqlTypes.isTimestampLtz, SqlTypes);
  this.isTimestampNtz = createFnIsColumnOfType(type, SqlTypes.isTimestampNtz, SqlTypes);
  this.isTimestampTz  = createFnIsColumnOfType(type, SqlTypes.isTimestampTz, SqlTypes);
  this.isVariant      = createFnIsColumnOfType(type, SqlTypes.isVariant, SqlTypes);
  this.isObject       = createFnIsColumnOfType(type, SqlTypes.isObject, SqlTypes);
  this.isArray        = createFnIsColumnOfType(type, SqlTypes.isArray, SqlTypes);

  var convert;
  var toString;
  var toValue;
  var format;

  if (this.isNumber())
  {
    convert  = convertRawNumber;
    toValue  = toValueFromNumber;
    toString = toStringFromNumber;
  }
  else if (this.isTime())
  {
    convert  = convertRawTime;
    toValue  = toValueFromTime;
    toString = toStringFromTime;
    format   = statementParameters['TIME_OUTPUT_FORMAT'];
  }
  else
  {
    toValue = noop;

    if (this.isBoolean())
    {
      convert  = convertRawBoolean;
      toString = toStringFromBoolean;
    }
    else if (this.isDate())
    {
      convert  = convertRawDate;
      toString = toStringFromDate;
      format   = statementParameters['DATE_OUTPUT_FORMAT'];
    }
    else if (this.isTimestamp())
    {
      if (this.isTimestampLtz())
      {
        convert  = convertRawTimestampLtz;
        toString = toStringFromTimestamp;
        format   = statementParameters['TIMESTAMP_LTZ_OUTPUT_FORMAT'];
      }
      else if (this.isTimestampNtz())
      {
        convert  = convertRawTimestampNtz;
        toString = toStringFromTimestamp;
        format   = statementParameters['TIMESTAMP_NTZ_OUTPUT_FORMAT'];
      }
      else if (this.isTimestampTz())
      {
        convert  = convertRawTimestampTz;
        toString = toStringFromTimestamp;
        format   = statementParameters['TIMESTAMP_TZ_OUTPUT_FORMAT'];
      }

      // if we don't have a type-specific timezone, use the default format
      if (!format)
      {
        format = statementParameters['TIMESTAMP_OUTPUT_FORMAT'];
      }
    }
    else if (this.isBinary())
    {
      convert = convertRawBinary;
      toString = toStringFromBinary;
      format = statementParameters['BINARY_OUTPUT_FORMAT'];
    }
    else if (this.isVariant())
    {
      convert  = convertRawVariant;
      toString = toStringFromVariant;
    }
    else
    {
      // column is of type string, so leave value as is
      convert  = noop;
      toString = toStringFromString;
    }
  }

  // create a private context to pass to the extract function
  var context =
  {
    convert             : convert,
    toValue             : toValue,
    toString            : toString,
    format              : format,
    resultVersion       : resultVersion,
    statementParameters : statementParameters
  };

  /**
   * Returns the value of this column in a row.
   *
   * @param {Object} row
   *
   * @returns {*}
   */
  this.getRowValue = function(row)
  {
    return extractFromRow.call(this, row, context, false);
  };

  /**
   * Returns the value of this in a row as a String.
   *
   * @param {Object} row
   *
   * @returns {String}
   */
  this.getRowValueAsString = function(row)
  {
    return extractFromRow.call(this, row, context, true);
  };
}
1348534
public String getColumnClassName(int column) throws SQLException {
    Field field = getField(column);
    String result = connection.getTypeInfo().getJavaClass(field.getOID());

    if (result != null) {
      return result;
    }

    int sqlType = getSQLType(column);
    switch (sqlType) {
      case Types.ARRAY:
        return ("java.sql.Array");
      default:
        String type = getPGType(column);
        if ("unknown".equals(type)) {
          return ("java.lang.String");
        }
        return ("java.lang.Object");
    }
  }
565818
private void fetchColumns() {

        Vector temp     = new Vector(20);
        Vector tempType = new Vector(20);

        try {
            if (cConn == null) {
                return;
            }

            if (dbmeta == null) {
                dbmeta = cConn.getMetaData();
            }

            ResultSet colList = dbmeta.getColumns(null, null, tableName, "%");

            while (colList.next()) {
                temp.addElement(colList.getString("COLUMN_NAME"));
                tempType.addElement(new Short(colList.getShort("DATA_TYPE")));
            }

            colList.close();
        } catch (SQLException e) {
            ZaurusEditor.printStatus("SQL Exception: " + e.getMessage());
        }

        columns = new String[temp.size()];

        temp.copyInto(columns);

        columnTypes = new short[temp.size()];

        for (int i = 0; i < columnTypes.length; i++) {
            columnTypes[i] = ((Short) tempType.elementAt(i)).shortValue();
        }
    }
660038
static SplittedSql generateSQL(final SQLiteModelMethod method, MethodSpec.Builder methodBuilder, final boolean replaceProjectedColumns) {
		JQLChecker jqlChecker = JQLChecker.getInstance();

		final SplittedSql splittedSql = new SplittedSql();

		String sql = convertJQL2SQL(method, false);

		// parameters extracted from JQL converted in SQL
		splittedSql.sqlBasic = jqlChecker.replaceVariableStatements(method, sql, new JQLReplaceVariableStatementListenerImpl() {

			@Override
			public String onWhere(String statement) {
				splittedSql.sqlWhereStatement = statement;
				return "";
			}

			@Override
			public String onOrderBy(String statement) {
				splittedSql.sqlOrderByStatement = statement;
				return "";
			}

			@Override
			public String onOffset(String statement) {
				splittedSql.sqlOffsetStatement = statement;
				return "";
			}

			@Override
			public String onLimit(String statement) {
				splittedSql.sqlLimitStatement = statement;
				return "";
			}

			@Override
			public String onHaving(String statement) {
				splittedSql.sqlHavingStatement = statement;
				return "";
			}

			@Override
			public String onGroup(String statement) {
				splittedSql.sqlGroupStatement = statement;
				return "";
			}

			@Override
			public String onProjectedColumns(String statement) {
				if (replaceProjectedColumns)
					return "%s";
				else
					return null;
			}
		});

		return splittedSql;
	}
139340
public static String columnTypeAsString(SQLProperty property) {
		if (property.columnAffinityType != null && ColumnAffinityType.AUTO != property.columnAffinityType) {
			return property.columnAffinityType.toString();
		}

		TypeName typeName = property.getPropertyType().getTypeName();
		if (property.hasTypeAdapter()) {
			typeName = typeName(property.typeAdapter.dataType);
		}

		SQLTransform transform = lookup(typeName);

		if (transform == null) {
			throw new IllegalArgumentException("Transform of " + property.getElement().asType() + " not supported");
		}
		return transform.getColumnType().toString();

	}
844322
@Override
    public ResultSet getTypeInfo() throws SQLException
    {
        checkClosed();
        this.sysCatalog.setString(1, "TYPEINFO");
        ResultSet res = this.sysCatalog.executeQuery();
        return res;
    }
499023
public static String toSingleColumnSql(String sql) {
		String tempSql = sql.trim();
		String regex = "(?i)^select(.*?)from";
		Matcher m = Pattern.compile(regex).matcher(tempSql);
		String columnAlias = SqlTemplate.SINGLE_COLUMN_ALIAS;
		if (m.find()) {
			columnAlias = m.group(1).trim().replaceAll("\\(\\s+", "(").replaceAll("\\s+\\)", ")").split("\\s+")[0]+ " AS " + columnAlias;
		}
		return tempSql.replaceFirst(regex, "select " + columnAlias + " from ");
	}
1372729
public void getSQLFromField(PreparedStatement statement, int iType, int iParamColumn) throws SQLException
    {
        if (this.isNull())
            statement.setNull(iParamColumn, Types.BIT);
        else
        {
            String strBitSupported = DBConstants.TRUE;
            if (this.getRecord() != null)
                if (this.getRecord().getTable() != null)
                    if (this.getRecord().getTable().getDatabase().getProperties() != null)
                strBitSupported = (String)this.getRecord().getTable().getDatabase().getProperties().get(SQLParams.BIT_TYPE_SUPPORTED);
            if (DBConstants.TRUE.equals(strBitSupported))
                statement.setBoolean(iParamColumn, this.getState());
            else
                statement.setByte(iParamColumn, (this.getState() ? (byte)1 : (byte)0));
        }
    }
1110524
public String[] getColumnsBySql(Sql sql) throws SQLException {
		String columns[] = null;
		
		List<Map<String, String>> table = getMetadataBySql(sql);
		if (table != null) {
			columns = new String[table.size()];
			for (int i = 0 ; i < table.size() ; i++) {
				Map<String, String> row = table.get(i);
				if (row.containsKey("NAME") && row.get("NAME") != null) {
					columns[i] = row.get("NAME");
				}
			}
		}
		
		return columns;
	}