Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V3.0 #69

Merged
merged 24 commits into from
Nov 13, 2015
Merged

V3.0 #69

merged 24 commits into from
Nov 13, 2015

Conversation

msiemens
Copy link
Owner

This PR prepares an overhaul of TinyDB released as version 3.0.

Notable changes:

  • New Query model:
    • where('...').contains('...') has been renamed to where('...').search('...') to indicate that it works on regexes
    • Support for ORM-like usage: User = Query(); db.find(User.name == 'John')
    • where('foo') is an alias for Query().foo
    • where('foo').has('bar') is replaced by either where('foo').bar or Query().foo.bar
      • In case the key is not a valid Python identifier, array notation can be used: where('a.b.c') is now Query()['a.b.c']
    • Checking for the existence of a key has to be done explicitely: where('foo').exists()
  • Migrations from v1 to v2 have been removed
  • SmartCacheTable has been moved to msiemens/tinydb-smartcache
  • Serialization has been moved to msiemens/tinydb-serialization

Todo:

Closes #62, #67, #70

Up to now there was a circular relationship between the database object and the
table objects. Now each table gets a StorageProxy which forwards read and write
operations to the storage and allows access only to the corresponding table data.

Also, the database object is now responsible for cleaning up the storage. The
table objects can no longer be used as a context manager (as suggested by
@krisztianfekete in #70). In addition, the database object will close the storage
if it is garbage collected and `close` hasn't been called yet.

See discussion in #70
@msiemens
Copy link
Owner Author

msiemens commented Nov 7, 2015

I've finally gotten around to finish the missing bits.

@eugene-eeo Could you have a look at this whether we're missing something for v3.0?

@eugene-eeo
Copy link
Contributor

@msiemens you probably want to expose some API for clearing the cache "properly"- at the moment tinyrecord relies on the _cache dictionary (once we have that done perhaps I should look at improving the isolation and correctness of transactions in tinyrecord, perhaps by holding a DB-local lock). I especially like the new Query implementation and how it looks more like an ORM while probably performing better and having less code to maintain than the old model. 👍

I especially like the Query modifiers- so elegant! A little critique but I would probably use a frozenset to represent the __and__ and __or__ "nodes" just so that it is more correct- A AND B is the same as B AND A, and the same applies to A OR B, mathematically.

- Add a `clear_cache` method to Tables
- Make OR and AND operations on queries commutative
@msiemens
Copy link
Owner Author

you probably want to expose some API for clearing the cache "properly"

Good idea, I've added Table.clear_cache.

A little critique but I would probably use a frozenset to represent the and and or "nodes" just so that it is more correct- A AND B is the same as B AND A, and the same applies to A OR B, mathematically.

Good point! I've updated the AND and OR operations to be commutative.

As always, thanks for your insight, @eugene-eeo!

msiemens added a commit that referenced this pull request Nov 13, 2015
Merge V3.0 again?? GitHub acts strange today...
@msiemens msiemens merged commit ce96274 into master Nov 13, 2015
@msiemens msiemens deleted the v3.0 branch November 13, 2015 12:58
@msiemens
Copy link
Owner Author

TinyDB v3.0.0 is now officially released 🎉

@msiemens msiemens changed the title [WIP] V3.0 V3.0 Nov 13, 2015
msiemens added a commit that referenced this pull request Feb 19, 2016
Looks like I forgot to update the documentation after renaming Query.contains to Query.search.

See #69
Closes #93
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants