Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kodumbeats opened this issue Dec 15, 2021 · 1 comment
Open

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

kodumbeats opened this issue Dec 15, 2021 · 1 comment

Comments

@kodumbeats
Copy link
Contributor

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
@fogelito
Copy link
Contributor

I think there is another Issue here the size is the length of the coumn , like size 6 = 100000 digits for unsigned value.
while getIntLimit refferst to the value of he int not the length...

like string 64 meaning 64 chars length.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants