Default Generators

Foxglove provides default generators based on columns' metadata.

See Default spec by JDBC Type for more details.

Global setting

  • You can get the global setting by DataSetting.default().

  • The DataSetting provides various methods to change how values are generated for columns.

See Settings for more details.

Default behavior by DDL

DDL provides some definitions about the columns, Foxglove's default behavior over column definitions are(sorted by priority):

  1. Generated(FALSE) - Won’t generate values

  2. Auto Increament(FALSE) - Won’t generate values

  3. Nullable(TRUE) - Generate viable(random) values

  4. Default value(TRUE) - Generate viable(random) values


  • Any column has any of above properties will follow the TRUE/FALSE to decide whether or not to generate the value automatically.

  • If a column has none of above properties, Foxglove will generate viable(random) values for it.

  • You can change the behavior by DataSetting.autoGenerateFor() and DataSetting.notAutoGenerateFor().

  • For nullable column, you can generate possible NULL value by setting DataSetting.generateNull(true) or ValueSpec's nullable() method.

Note
These properties are ignored if a TableFacet define its own logic for a matched column.

See DataSetting of javadoc for more details.

Default number of rows

Note
The default number of rows(to be generated) is 1024.

Use DataSetting.setDefaultNumberOfRows(int) to change the it.

Default spec by JDBC Type

Depends on java.sql.JDBCType, Foxglove provides default generators for:

For integral data

The min value of integral types would be equals to 0.

JDBC Type

Default Generator

BIT, BOOLEAN

BooleanSpec

TINYINT

ByteSpec

SMALLINT

ShortSpec

INTEGER

IntegerSpec

BIGINT

LongSpec

For floating point data

JDBC Type

Default Generator

FLOAT, REAL

FloatSpec

Min value would be equals to 0.0f.

DOUBLE

DoubleSpec

Min value would be equals to 0.0f.

NUMERIC, DECIMAL

BigDecimalSpec

For BigDecimalSpec, the precision would be equals to ColumnMeta.size(), ColumnMeta.decimalDigits().


TODO: PostgreSQL supports negative value of scale for NUMERIC(4, -3), which should be implemented specifically.

Special note of PostgreSQL

PostgreSQL permits the scale in a numeric type declaration to be any value in the range -1000 to 1000. However, the SQL standard requires the scale to be in the range 0 to precision. Using scales outside that range may not be portable to other database systems.

See PostgreSQL Numeric Types for more details.

For text data

By default, all of characters type are generated by alphaNumeric() of StringGeneratorSpec.

For CHAR, VARCHAR, NCHAR, NVARCHAR

ColumnMeta.size()

ValueGenerator

⇐ 8(less than or equal to 8)

Same as ColumnMeta.size()

> 8 && ⇐ 32(between 8 and 32)

Length is between 8 and ColumnMeta.size()

> 32(more than 32)

Length is between 32 and Math.min(ColumnMeta.size(), 128)

For LONGVARCHAR, CLOB, LONGNVARCHAR, NCLOB
  • Generate text with length between 1024 and 2048.

Customization of large text:

  • Use DataSetting.largeTextLength(minLength, maxLength) to change the random length for large text columns.

For date/time/timestamp

JDBC Type

Default Generator

DATE

LocalDateSpec

TIME

LocalTimeSpec

TIMESTAMP

LocalDateTimeSpec

TIME_WITH_TIMEZONE

OffsetTimeSpec

TIMESTAMP_WITH_TIMEZONE

ZonedDateTimeSpec

For binary data

By default, all of binary type are generated by ByteSpec.

For BINARY, VARBINARY

ColumnMeta.size()

ValueGenerator

⇐ 16(less than or equal to 16). UUID is 16 bytes.

Same as ColumnMeta.size()

> 16 && ⇐ 64(between 16 and 64)

Length is between 16 and ColumnMeta.size()

> 64(more than 64)

Length is between 64 and Math.min(ColumnMeta.size(), 256)

For LONGVARBINARY, BLOB
  • Generate binary with length between 1024 and 2048.

Special types

By type name

Not supported JDBCTypes

  • ARRAY, STRUCT

    • TODO: Oracle, PostgreSQL support array/struct types.

  • ROWID, NULL, JAVA_OBJECT, DISTINCT, OTHER

  • SQLXML - Won’t generate values

    • TODO: Oracle, PostgreSQL, SQL Server support array/struct types.

  • REF, REF_CURSOR, DATALINK