Skip to content

Commit 21c5fb6

Browse files
authored
Merge pull request #55 from keboola/jirka-add-max-length-to-snflk
Add constants for max length in snflk
2 parents e57f8e7 + 180b83d commit 21c5fb6

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

src/Definition/Redshift.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ private function validateLength(string $type, $length = null): void
166166
$valid = false;
167167
break;
168168
}
169-
if (isset($parts[1]) && ((int) $parts[1] > (int) $parts[0] || (int) $parts[1] > 37)) {
169+
if (isset($parts[1]) && ((int) $parts[1] > 37 || (int) $parts[1] > (int) $parts[0])) {
170170
$valid = false;
171171
break;
172172
}
@@ -175,7 +175,6 @@ private function validateLength(string $type, $length = null): void
175175
case 'CHARACTER VARYING':
176176
case 'TEXT':
177177
case 'NVARCHAR':
178-
case 'TEXT':
179178
if (is_null($length) || $length === '') {
180179
break;
181180
}

src/Definition/Snowflake.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ class Snowflake extends Common
7575
self::TYPE_VARBINARY,
7676
];
7777

78+
public const MAX_VARCHAR_LENGTH = 16777216;
79+
public const MAX_VARBINARY_LENGTH = 8388608;
80+
7881
/**
7982
* Snowflake constructor.
8083
*
@@ -207,7 +210,7 @@ private function validateLength(string $type, $length = null): void
207210
$valid = false;
208211
break;
209212
}
210-
if (isset($parts[1]) && ((int) $parts[1] > (int) $parts[0] || (int) $parts[1] > 38)) {
213+
if (isset($parts[1]) && ((int) $parts[1] > 38 || (int) $parts[1] > (int) $parts[0])) {
211214
$valid = false;
212215
break;
213216
}
@@ -224,7 +227,7 @@ private function validateLength(string $type, $length = null): void
224227
$valid = false;
225228
break;
226229
}
227-
if ((int) $length <= 0 || (int) $length > 16_777_216) {
230+
if ((int) $length <= 0 || (int) $length > self::MAX_VARCHAR_LENGTH) {
228231
$valid = false;
229232
break;
230233
}
@@ -256,7 +259,7 @@ private function validateLength(string $type, $length = null): void
256259
$valid = false;
257260
break;
258261
}
259-
if ((int) $length < 1 || (int) $length > 8_388_608) {
262+
if ((int) $length < 1 || (int) $length > self::MAX_VARBINARY_LENGTH) {
260263
$valid = false;
261264
break;
262265
}

0 commit comments

Comments
 (0)