Page 1 of 1

TUniMetaData: MySql - precision of DateTime

Posted: Fri 24 Oct 2014 15:59
by martin.trummer
when I use TUniMetaData to read the metadata of a MySQL table, I have a problem with DateTime fields. The precision is not correct - it is always 0.

i.e. when you create this table:

Code: Select all

CREATE TABLE `Test` 
(
`Id` datetime(3) NOT NULL 
)
I'd expect that TUniMetaData returns 3 for the Precision of the Id field, but it returns 0.

Is this a bug? Does anyone know a simple workaround?

Re: TUniMetaData: MySql - precision of DateTime

Posted: Tue 28 Oct 2014 10:17
by ViktorV
UniDAC doesn't support retrieving of datetime precision for the new MySQL server versions. We will investigate the possibility of adding this functionality in the future.
As soon as we solve this question we will let you know.

Re: TUniMetaData: MySql - precision of DateTime

Posted: Mon 03 Nov 2014 14:13
by martin.trummer
workaround is to read the required data directly from the database info schema with a TUniQuery. e.g.

Code: Select all

select TABLE_NAME
 , COLUMN_NAME
 , DATA_TYPE
 , IF(DATA_TYPE = 'datetime', DATETIME_PRECISION, NUMERIC_PRECISION) as DATA_PRECISION 
 , NUMERIC_SCALE as DATA_SCALE
 , IS_NULLABLE as NULLABLE
from INFORMATION_SCHEMA.COLUMNS
#where TABLE_SCHEMA = 'xxx'
# and TABLE_NAME = 'xxx'
order by TABLE_NAME, ORDINAL_POSITION;

Re: TUniMetaData: MySql - precision of DateTime

Posted: Tue 04 Nov 2014 08:39
by ViktorV
Thank you for the information and the provided solution. We will add this functionality in one of the next builds.