GodotNuts / GodotFirebase

Implementations of Firebase for Godot using GDScript
MIT License
517 stars 74 forks source link

[FEATURE REQUEST] FirestoreDocument.document values to be of their respective types (the content integerValue to be int instead of String) #412

Closed thiscris closed 4 weeks ago

thiscris commented 4 weeks ago

Is your feature request related to a problem? Please describe. The following code gives an error, because score.integerValue is stored as a String and needs to be enclosed in an int()

var result := await Firebase.Firestore.query(query)
for i:FirestoreDocument in result:
    var n:String = i.document.name.stringValue
    var s:int = i.document.score.integerValue

Describe the solution you'd like the plugin is aware of the data type, otherwise it wouldn't have the Dictionary keys called "stringValue" and "integerValue". It should convert the values in the dictionary in their respective types during retrieval

Describe alternatives you've considered I wanted to share this idea on discord, but since the server requires phone verification and I don't want to do that, I am writing directly here.

Additional context Previous versions of the plugin used to return the correct data types.

WolfgangSenff commented 4 weeks ago

You should not be using the integerValue. You're using the result all wrong. How you would do that is this:

var result := await Firebase.Firestore.query(query) for i:FirestoreDocument in result: var n:String = i.get_value("name") var s:int = i.get_value("score")

Please make sure to read the wiki fully before requesting stuff like this - pretty much a two person shop at this point. :) That all said, I just ran a test and it's still returning strings for it due to how we have to stringify the data. I think it did that in the past also, but it's something I have wanted to fix, so I'm going to look into it.

WolfgangSenff commented 4 weeks ago

Alright, this is updated and fixed. You should now always get back the correct type as long as you're using the plugin correctly!