utopia-php / utopia-php/database

`Utopia\Database\Adapter::getIntLimit()` is not enforced

Open
#94 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
74
Forks
59
Avg merge
10h 45m
Merged PRs (30d)
20

Description

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:

https://github.com/utopia-php/database/blob/af512b7a00cc7c6e30fa03efbc5fd7e77a93e2df/src/Database/Database.php#L433-L437

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the createAttribute() check in src/Database/Database.php at the linked lines, then trace how integer attributes currently set $size and how adapters implement getIntLimit(). Compare the two enforcement options described in the issue and define the expected behavior for create and update paths. Done means integer limits are enforced consistently without relying on an unhandled PDO database exception.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
databases
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.