Back

Db attribute required/array console UI vs CLI

  • 2
  • Tools
  • Databases
Tanner Meade
27 Mar, 2023, 20:16

When creating an attribute via the console UI vs the CLI there is a difference in the functionality.

The console UI will not allow you to create an array that is "required". When the array box is checked the grays out the required box.

The CLI create attribute commands require the "required" tag and you can successfully create a required array attribute which can not be done in the console UI.

Which is accurate and which is a bug?

TL;DR
The user is reporting an issue with creating required array attributes in the console UI vs the CLI. In the console UI, the "required" field becomes grayed out when the array box is checked, indicating that it is not possible to create a required array. However, in the CLI, it is possible to create a required array attribute. The reason for this difference is that in the Utopia-php database module used by Appwrite, the attribute creation code does not include any requirements or null statements. It is unclear whether the behavior in the console UI or the CLI is accurate and which one is a bug. Solution:
Binyamin
27 Mar, 2023, 20:26

It won't matter in both cases When you're creating string attribute as array it will always going to be an array.

That means that the default value would be [] so the value will be filled in any case.

The reason that the Required field become gray it's just to let you know that there is no use to declare it as required.

If you will look here in the Utopia-php database module (this is what Appwrite uses for DB) https://github.com/utopia-php/database/blob/main/src/Database/Database.php#L776

You will find the attribute creation code

TypeScript
$attribute = $this->adapter->createAttribute($collection->getId(), $id, $type, $size, $signed, $array);

And in Appwrite it uses the MariaDB adapter https://github.com/utopia-php/database/blob/main/src/Database/Adapter/MariaDB.php#L173

TypeScript
 return $this->getPDO()
  ->prepare("ALTER TABLE {$this->getSQLTable($name)} ADD COLUMN `{$id}` {$type};")
  ->execute();

And you can see that the field is going to be created with out any requirements or no null statements

Tessa
6 Jun, 2023, 16:00

bug report also here: https://github.com/appwrite/console/issues/461

@Steven ? do you know if we are making improvements on this page?

Drake
6 Jun, 2023, 16:10

not that i know of

Tessa
6 Jun, 2023, 16:18

okay, added to our DX thread for improvements 🙂 good to know

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more