gives an error in 1.3.1
Interesting...I don't think it should throw an error...
oh interesting..it does throw an error...
it would probably be good to create an issue for this. i would like to allow empty strings, but we should get more feedback from users and the team
btw, i don't think it's a problem with falsy values...it's just that we aren't allowing empty strings as default for string attributes
ahh. do you see any way around
I am using Go and without an SDK. This is relevant because Go doesn't allow bool(value) to filter out falsy value and I am stuck ๐ The only way I see is to write a switch statement for every single data type and iterate through params.
I'm not quite sure why the falsy check is needed? what are you trying to do?
trying to filter out empty strings
it turns out get requests dont support it either
Default != ""
or was there something else you were trying to do?
I mean it works for string attributes but there's also int attribute and float attribute and enum attribute for database, query and search for list* endpoints
I'll just wait for github issue to see if y'all revert back to supporting empty values should I close this post?
the github issue is going to be focused on allowing empty strings as default value when creating an attribute. I think your problem is kind of unrelated
sorry i really don't understand what you're trying to do so it's hard to provide an adequate answer.
That said, there is a Value.IsZero()
that might be helpful for you: https://stackoverflow.com/questions/13901819/quick-way-to-detect-empty-values-via-reflection-in-go
I am trying to complete the go sdk at https://github.com/appwrite/sdk-for-go Its painful because go doesn't have default values for function arguments. I just realized that with my current approach for integer arguments, there's no way to differentiate if the user passed zero because they dont want a default argument or because they want a default value of 0 ๐คฆโโ๏ธ
Up until now I only considered string argument so if the user passed an empty argument (for example to search parameter of listCollection) it was safe to assume it could be excluded from the request
you know we the SDK needs to be created by our SDK generator, right?
For integers, the API should allow 0 and null.
as of 1.3, i think we handle 3 different cases distinctly:
- value provided
- null
- no value provided
From the SDK perspective, the function should expect a nullable string and pass that along
The problem is still the same. My assumption was to have the user provide falsy values for optional arguments and filter it out in Client class when sending the request. This doesn't work for integers. I realized it doesn't work for integers during this chat.
Since Go needs a definite type for a function so it cant be string or null. Technically it can be a pointer type which allows nil but then the user has to do &"Hello" which is just annoying.
heh...it looks like in dart, we remove values if they are null: https://github.com/appwrite/sdk-for-dart/blob/58120822b89791993a8a8a87ba2f6245555005df/lib/src/client_mixin.dart#L15
Maybe you should just do the same
Unfortunately go doesn't have null type. At least one that can be used instead of any type of variable
The equivalent should be nil
Recommended threads
- Attributes Confusion
```import 'package:appwrite/models.dart'; class OrdersModel { String id, email, name, phone, status, user_id, address; int discount, total, created_at; L...
- I recently applied for the free plan und...
I recently applied for the free plan under the GitHub Student Developer Pack. However, my billing status still shows $15, and it mentions that this amount will ...
- Bug Report: Appwrite Console UI Issue on...
Steps to Reproduce: - Navigate to any collection page in the Appwrite console UI. - Open the menu and click on "Create Collection." - Observe that the dialog to...