octabytes / FireO

Google Cloud Firestore modern and simplest convenient ORM package in Python. FireO is specifically designed for the Google's Firestore
https://fireo.octabyte.io
Apache License 2.0
247 stars 29 forks source link

version 2.0.0 error with ListUnion/ListRemove #202

Closed trungtin closed 1 year ago

trungtin commented 1 year ago

The released version 2.0.0 throw the error ListUnion object is not iterable. I saw that it had been fixed in the main branch. Could you release the new version?

trungtin commented 1 year ago

In fact, the issue is still there in the master branch.

If I define the schema like this, no error

class User(Model):
  subjects = ListField()  

u = User()
u.subjects = ['English', 'Math']

But with this (just like in the documentation), the error appears.

subjects = ListField(TextField())  
ADR-007 commented 1 year ago

Hi @trungtin,

Could you please describe how to reproduce the issue?

I just tried this on master branch and it works:

from fireo import ListUnion
from fireo.fields import ListField, TextField
from fireo.models import Model

class User(Model):
    subjects = ListField()

class User2(Model):
    subjects = ListField(TextField())

def test():
    u = User()
    u.subjects = ['English', 'Math']
    u.save()

    u.subjects = ListUnion(['Geography', 'History'])
    u.update()

    u.refresh()

    assert u.subjects == ['English', 'Math', 'Geography', 'History']

def test2():
    u = User2()
    u.subjects = ['English', 'Math']
    u.save()

    u.subjects = ListUnion(['Geography', 'History'])
    u.update()

    u.refresh()

    assert u.subjects == ['English', 'Math', 'Geography', 'History']
trungtin commented 1 year ago

Sorry, my stupid ass thought I was running on the master branch but not.

Anyway, do we have a new version release soon?

ADR-007 commented 1 year ago

This is a question for @AxeemHaider :)

AxeemHaider commented 1 year ago

New version 2.1.0 is available with the help of @ADR-007 :)