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

🐛 Bug Report: Error updating properties of required attributes using dart-sdk #66

Open
2 tasks done
ShivanshuKGupta opened this issue Oct 16, 2024 · 0 comments
Open
2 tasks done
Labels
bug Something isn't working

Comments

@ShivanshuKGupta
Copy link

👟 Reproduction steps

  1. Create a new collection with a string attribute with required = true and give a max size of 255.
  2. Try to update only the max size of this attribute using dart-sdk.

Sample code:

import 'package:dart_appwrite/dart_appwrite.dart';
import 'package:televolution_sync/appwrite/appwrite.dart';

void main() async {
  final client = Client()
    ..setEndpoint(constants.endpoint)
    ..setProject(constants.projectId)
    ..setKey(constants.apiKey)
    ..setSelfSigned(status: true);

  final databases = Databases(client);

  final nameAttribute = await databases.getAttribute(
    databaseId: 'TEST',
    collectionId: 'TESTCOLLECTION',
    key: 'name',
  );

  print('nameAttribute = $nameAttribute');
  // Output of above line:
  // nameAttribute = {key: name, type: string, status: available, error: , required: true, array: false, size: 255, default: null}

  /// Now, I will try to update the size to 1000 (previously 255)
  final updatedAttribute = await databases.updateStringAttribute(
    databaseId: 'TEST',
    collectionId: 'TESTCOLLECTION',
    key: 'name',
    size: 1000,
    xdefault: null, // I also tried these values here: ("", "no name", null), but I get errors on all of them.
    xrequired: true,
  );

  print('updatedAttribute = $updatedAttribute'); // Never reached this line
}

👍 Expected behavior

The attribute should be updated with the new size.

👎 Actual Behavior

Get an error related to default value:

  1. If you try to keep null as the default value:
    Image

  2. If you try to give some other default value (which shouldn't be the case, because the attribute is required by nature):
    Image

🎲 Appwrite version

Different version (specify in environment)

💻 Operating system

Something else

🧱 Your Environment

Appwrite Cloud Version: 1.6.0
Dart Version: 3.1.5
Dart SDK Version: dart_appwrite 12.1.0

The code doesn't work, neither from my local machine nor from an appwrite function.

👀 Have you spent some time to check if this issue has been raised before?

  • I checked and didn't find similar issue

🏢 Have you read the Code of Conduct?

@ShivanshuKGupta ShivanshuKGupta added the bug Something isn't working label Oct 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant