Hi all,
The current data type information for describing or creating database
fields (or resultset columns) is not precise enough for many purposes.
The DatabaseMetadata.FieldDescription type holds a ValueType along
with a 'valueLength' Int to represent the data type.
The next Open Quark release will include a new SqlType which more
closely matches the data types supported by JDBC and most databases.
In addition to representing SQL data types more precisely, parameters
of the types have been added where appropriate.
For example, Numeric and Decimal types include the precision and scale
values.
Char and VarChar types include the number (or maximum number) of
characters.
There is no longer need for a separate length value, which doesn't
apply to most types anyway.
The DatabaseMetadata.FieldDescription now uses SqlType instead of
ValueType and the 'length' Int value.
As a result, this information is available when querying database
field information.
Also, when creating tables through the Sql model, there is now much
more control over what types will be created on the database.
The SqlType data constructors are based on the JDBC type constants
(see java.sql.Types).
The SqlBuilder attempts to map these types to the closest types for
each supported database type, but sometimes the mappings are not
simple.
Here is a snippet of code from the new SqlType type:
/**
* SqlType includes a classification of a SQL data type, as well
as more detailed information
* (such as length or precision) of certain data types.
* This corresponds to the {@code java.sql.Types@} JDBC type
constants.
*/
data public SqlType =
/**
* The SmallInt type is for integer values (typically 8-bit).
*/
public SqlType_TinyInt
|
/**
* The SmallInt type is for integer values (typically 16-bit).
*/
public SqlType_SmallInt
|
/**
* The Integer type is for integer values (typically 32-bit).
*/
public SqlType_Integer
|
/**
* The Integer type is for integer values (typically 64-bit).
*/
public SqlType_BigInt
|
/**
* The Decimal type is a fixed-precision numeric type.
* The total number of digits (precision) and the number of
digits to the right of the
* decimal point (scale) can be specified.
* Decimal values are intended to be stored with the specified
precision or higher
* (whereas Numeric values should use exactly the specified
precision).
* @arg precision the total number of digits in the value
* @arg scale the number of digits to the right of the
decimal point (cannot be
* greater than the precision value)
*/
public SqlType_Decimal
precision :: !Int
scale :: !Int
|
/**
* The Numeric type is a fixed-precision numeric type.
* The total number of digits (precision) and the number of
digits to the right of the
* decimal point (scale) can be specified.
* Numeric values are intended to be stored with exactly the
specified precision
* (whereas Double values can use the specified
* precision or higher).
* @arg precision the total number of digits in the value
* @arg scale the number of digits to the right of the
decimal point (cannot be greater
* than the precision value)
*/
public SqlType_Numeric
precision :: !Int
scale :: !Int
|
/**
* The Real type is a floating-point numeric type (typically
with 7 digits of mantissa).
*/
public SqlType_Real
|
/**
* The Float type is a floating-point numeric type (typically
with 15 digits of mantissa).
*/
public SqlType_Float
|
/**
* The Double type is a floating-point numeric type (typically
with 15 digits of mantissa).
*/
public SqlType_Double
|
/**
* The Bit type handles a single bit values (on/off).
*/
public SqlType_Bit
|
/**
* The Boolean type is for True/False values.
*/
public SqlType_Boolean
|
/**
* The Char type is a fixed-length character string type.
* The fixed number of characters is specified.
* Shorter values will be padded with trailing spaces.
* @arg length the number of characters in the string
*/
public SqlType_Char
length :: !Int
|
/**
* The VarChar type is a variable-length character string
type.
* The maximum number of characters is specified.
* @arg length the maximum number of characters in the string
*/
public SqlType_VarChar
length :: !Int
|
/**
* The LongVarChar type handles variable-length character
strings which could be very long.
*/
public SqlType_LongVarChar
|
/**
* The CLOB (Character Large Object) type handles variable-
length character
* strings which could be very long.
*/
public SqlType_Clob
|
/**
* The Binary type is a fixed-length binary type
* @arg length the number of bytes in the binary values
*/
public SqlType_Binary
length :: !Int
|
/**
* The VarBinary type is a variable-length binary type.
* @arg length the maximum number of bytes in the binary
values
*/
public SqlType_VarBinary
length :: !Int
|
/**
* The LongVarBinary type handles variable-length binary
values which could be very long.
*/
public SqlType_LongVarBinary
|
/**
* The Blob type handles variable-length binary values which
could be very long.
*/
public SqlType_Blob
|
/**
* The Date type handles Year/Month/Day values.
*/
public SqlType_Date
|
/**
* The Time type handles Hour/Minute/Second values (and
possibly fractions of a second).
*/
public SqlType_Time
|
/**
* The TimeStamp type combines the Date an Time type
information, handling
* Year/Month/Day and Hour/Minute/Second.
*/
public SqlType_TimeStamp
|
... (less commonly-used data types omitted) ...
;
This change was made based on suggestions by Steve Harris on the
Google Group.
Thanks
Rich