Skip to content

Utopia\Database\Adapter::getIntLimit() is not enforced #94

@kodumbeats

Description

@kodumbeats

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions