Bug #81061 Unable to use for loop with add() for adding documents inside mysqlsh-py
Submitted: 13 Apr 2016 8:27 Modified: 13 Apr 2016 12:12
Reporter: Shahriyar Rzayev Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Document Store: X Plugin Severity:S2 (Serious)
Version:5.7.12 OS:Any
Assigned to: CPU Architecture:Any

[13 Apr 2016 8:27] Shahriyar Rzayev
Description:
Maybe there is some other way of doing this but it is clear from simple run:

mysql-py>for i in range(10):                                                                                                                                                        print 'f'                                                                                                                                                                    
f
f
f
f
f
f
f
f
f
f
Query OK, 1 item affected (0.00 sec)

Theoretically I must be able to run add() 1000 times using:

mysql-py>for i in range(1000):                                                                                                                                                      myColl.add({"GNP": .6,"IndepYear": 1967,"Name": "Sealand","_id": "SEA","demographics": {"LifeExpectancy": 79,"Population": 27},"geography": {"Continent": "Europe","Region": "British Islands","SurfaceArea": 193},"government": {"GovernmentForm": "Monarchy","HeadOfState": "Michael Bates"}})                                                             
Query OK, 1 item affected (0.00 sec)

How to repeat:
See description

Suggested fix:
Provide more info if we can use Python facilities inside mysqlsh-py?
[13 Apr 2016 12:12] MySQL Verification Team
Hello Shahriyar,

Thank you for the report!

Thanks,
Umesh
[7 Jul 2017 1:21] Alfredo Kojima
The add() method must be followed by .execute(). You can do what you want like:

op = coll
for doc in mydocs:
   op = op.add(doc)
op.execute()

That said, I'll leave the bug open for now because it illustrates a problem with clarity of the API.