5 ms·
Refactoring code for 1.4 in Python. Here are the fixes I've had to make so far (so everyone can reference): --Adjust imports Change: "from rethinkdb import r
by gsibble 14y ago
Refactoring code for 1.4 in Python. Here are the fixes I've had to make so far (so everyone can reference):
--Adjust imports
Change: "from rethinkdb import r"
To: "import rethinkdb as r"
--No more connection.run()
Change all your connection.run() to .run(connection)
For instance:
connection.run(r.db('test_db').table_create('test_table'))
becomes
r.db('test_db').table_create('test_table').run(connection)
--No more global connections
This one sucks IMHO. Took more than I'd like to refactor (still in progress). You have to explicitly pass a connection to every run() command. So this:
r.table('test_table').run()
becomes
r.table('test_table').run(C)
where C is a declared connection.
More notes as I find them....
- wmrowan 14y agoThanks for the notes gsibble, please let us know anywhere where we can make the docs more clear, especially anywhere the behavior has changed since 1.3. We appreciate your patience with the breaking changes. As for the changes to `connection.run` and `query.run` please note that in the Python driver you can call `.repl()` on any newly created connection to set that connection as a global default. This should replicate the old behavior. We decided that doing this by default was unsafe as it relied on global state modified any time a new connection is opened. Even so, we appreciate the convenience and kept the behavior in the form of the `.repl()` for when you're trying out RethinkDB in a simple script (or the Python REPL) that only creates one connection and doesn't use threads.
- gsibble 14y agoOh damn. Already halfway through refactoring. Can you update the change docs to note that? https://github.com/rethinkdb/rethinkdb/wiki/ReQL-changes-in-RethinkDB-1.4 https://github.com/rethinkdb/rethinkdb/wiki/ReQL-changes-in-... I don't see it on there.
- gsibble 14y agoAnother one: --Remove primary key definition from .get() No more primary key name is needed as a 2nd argument (and in fact breaks if you pass it). Just delete it.
- gsibble 14y agoAnd one more: --List of RDB objects is now a cursor, not a list Some iterations (notably for loops in jinja2) don't iterate properly. Need to pass them a real list by calling list() on the cursor.
- jdoliner 14y agoHow do they fail. Calling list() on cursor objects could be a really bad idea if they contain a lot of data since it will cause it all to be loaded in to memory.