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):
Generated(FALSE) - Won’t generate valuesAuto Increament(FALSE) - Won’t generate valuesNullable(TRUE) - Generate viable(random) valuesDefault value(TRUE) - Generate viable(random) values
Any column has any of above properties will follow the
TRUE/FALSEto 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()andDataSetting.notAutoGenerateFor().For nullable column, you can generate possible
NULLvalue by settingDataSetting.generateNull(true)or ValueSpec'snullable()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 | |
TINYINT | |
SMALLINT | |
INTEGER | |
BIGINT |
For floating point data
JDBC Type | Default Generator |
FLOAT, REAL | Min value would be equals to |
DOUBLE | Min value would be equals to |
NUMERIC, DECIMAL |
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.
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
1024and2048.
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 | |
TIME | |
TIMESTAMP | |
TIME_WITH_TIMEZONE | |
TIMESTAMP_WITH_TIMEZONE |
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
1024and2048.
Special types
- By type name
UUID- UUIDSpec
Not supported JDBCTypes
ARRAY,STRUCTTODO: Oracle, PostgreSQL support array/struct types.
ROWID,NULL,JAVA_OBJECT,DISTINCT,OTHERSQLXML- Won’t generate valuesTODO: Oracle, PostgreSQL, SQL Server support array/struct types.
REF,REF_CURSOR,DATALINK