Each adapter must implement the getIntLimit() method, but it isn't enforced due to how we interpret $size for integer attributes.
In the case of strings, $size is pretty obvious - the length of the string. However, for integers (and before BIGINT), we just set $size = 0, so this check in createAttribute() would never actually prevent PDO from throwing the database exception:
|
case self::VAR_INTEGER: |
|
$limit = ($signed) ? $this->adapter->getIntLimit() / 2 : $this->adapter->getIntLimit(); |
|
if($size > $limit) { |
|
throw new Exception('Max size allowed for int is: '.number_format($limit)); |
|
} |
Options to enforce int limit:
- Check values for
getIntLimit() as a filter when creating/updating documents
- Get PDO error codes when size is exceeded and throw a custom
Utopia\Database exception