@@ -132,7 +132,7 @@ class Teradata extends Common
132132 public const DEFAULT_BLOB_LENGTH = '1G ' ;
133133 public const DEFAULT_BYTE_LENGTH = 64000 ;
134134 public const DEFAULT_DATETIME_DIGIT_LENGTH = 4 ;
135- public const DEFAULT_DECIMAL_LENGTH = '38,38 ' ;
135+ public const DEFAULT_DECIMAL_LENGTH = '38,19 ' ;
136136 public const DEFAULT_LATIN_CHAR_LENGTH = 64000 ;
137137 public const DEFAULT_LATIN_CLOB_LENGTH = '1999M ' ;
138138 public const DEFAULT_NON_LATIN_CHAR_LENGTH = 32000 ;
@@ -201,7 +201,6 @@ class Teradata extends Common
201201 self ::TYPE_INTERVAL_SECOND ,
202202
203203 ];
204-
205204 // types where CHARAET can be defined
206205 public const CHARACTER_SET_TYPES = [
207206 self ::TYPE_CHAR ,
@@ -310,6 +309,11 @@ class Teradata extends Common
310309 self ::TYPE_REAL ,
311310 ];
312311
312+ // these types expect invalid default length given TD. e.g. NUMBER returns -128,-128. -> has to be redefined
313+ public const TYPES_WITH_INVALID_DEFAULT_LENGTH = [
314+ self ::TYPE_NUMBER => '-128,-128 ' ,
315+ ];
316+
313317 private bool $ isLatin = false ;
314318
315319 // depends on Char Type column in HELP TABLE column
@@ -328,6 +332,7 @@ public function __construct(string $type, array $options = [])
328332 }
329333
330334 $ this ->validateType ($ type );
335+ $ options ['length ' ] = $ this ->consolidateLength ($ type , $ options ['length ' ] ?? null );
331336 $ this ->validateLength ($ type , $ options ['length ' ] ?? null );
332337 $ diff = array_diff (array_keys ($ options ), ['length ' , 'nullable ' , 'default ' , 'isLatin ' ]);
333338 if ($ diff !== []) {
@@ -336,6 +341,23 @@ public function __construct(string $type, array $options = [])
336341 parent ::__construct ($ type , $ options );
337342 }
338343
344+ /**
345+ *
346+ * @param string $type
347+ * @param null $length
348+ * @return string|null
349+ */
350+ private function consolidateLength (string $ type , $ length = null ): ?string
351+ {
352+ if ($ length !== null
353+ && array_key_exists ($ type , self ::TYPES_WITH_INVALID_DEFAULT_LENGTH )
354+ && $ length === self ::TYPES_WITH_INVALID_DEFAULT_LENGTH [$ type ]
355+ ) {
356+ return $ this ->getDefaultLength ();
357+ }
358+ return $ length ;
359+ }
360+
339361 /**
340362 * @throws \Exception
341363 */
0 commit comments