Skip to content
This repository
Browse code

Cleaning up some notes

  • Loading branch information...
commit 105247d0ae45518138b0d848eb1fcc8f86d585fd 1 parent d9c6371
Charles Leifer authored October 05, 2012

Showing 1 changed file with 11 additions and 11 deletions. Show diff stats Hide diff stats

  1. 22  docs/peewee/upgrading.rst
22  docs/peewee/upgrading.rst
Source Rendered
@@ -28,7 +28,7 @@ I learned a valuable lesson:  keep data in datastructures until the
28 28
 *absolute* last second.
29 29
 
30 30
 With the benefit of hindsight and experience, I decided to rewrite and unify
31  
-the API a bit.  The result is a tradeoff.  The newer syntax may be a bit more 
  31
+the API a bit.  The result is a tradeoff.  The newer syntax may be a bit more
32 32
 verbose at times, but at least it will be consistent.
33 33
 
34 34
 Since seeing is believing, I will show some side-by-side comparisons.  Let's
@@ -51,7 +51,7 @@ Get me a list of all tweets by a user named "charlie":
51 51
 .. code-block:: python
52 52
 
53 53
     # 1.0
54  
-    Tweet.select().join(User).where(username='charlie') 
  54
+    Tweet.select().join(User).where(username='charlie')
55 55
 
56 56
     # 2.0
57 57
     Tweet.select().join(User).where(User.username == 'charlie')
@@ -60,8 +60,8 @@ Get me a list of tweets ordered by the authors username, then newest to oldest:
60 60
 
61 61
 .. code-block:: python
62 62
 
63  
-    # 1.0
64  
-    Tweet.select().order_by(('created_date', 'desc')).join(User).order_by('username')
  63
+    # 1.0 -- this is one where there are like 10 ways to express it
  64
+    Tweet.select().join(User).order_by('username', (Tweet, 'created_date', 'desc'))
65 65
 
66 66
     # 2.0
67 67
     Tweet.select().join(User).order_by(User.username, Tweet.created_date.desc())
@@ -89,7 +89,7 @@ Get me a list of users and when they last tweeted (if ever):
89 89
 
90 90
     # 1.0
91 91
     User.select({
92  
-        User: ['*'], 
  92
+        User: ['*'],
93 93
         Tweet: [Max('created_date', 'last_date')]
94 94
     }).join(Tweet, 'LEFT OUTER').group_by(User)
95 95
 
@@ -120,12 +120,12 @@ Let's find all the users whose username starts with 'a' or 'A':
120 120
 
121 121
 
122 122
 I hope a couple things jump out at you from these examples.  What I see is
123  
-that the 1.0 API is sometimes a bit less verbose, but it relies on strings in 
124  
-many places (which may be fields, aliases, selections, join types, functions, etc).  In the 
125  
-where clause stuff gets crazy as there are args being combined with bitwise 
126  
-operators ("Q" expressions) and also kwargs being used with django-style "double-underscore" 
  123
+that the 1.0 API is sometimes a bit less verbose, but it relies on strings in
  124
+many places (which may be fields, aliases, selections, join types, functions, etc).  In the
  125
+where clause stuff gets crazy as there are args being combined with bitwise
  126
+operators ("Q" expressions) and also kwargs being used with django-style "double-underscore"
127 127
 lookups. The crazy thing is, there are so many different ways I could have expressed
128  
-some of the above queries using peewee 1.0 that I had a hard time deciding which 
  128
+some of the above queries using peewee 1.0 that I had a hard time deciding which
129 129
 to even write.
130 130
 
131 131
 The 2.0 API is hopefully more consistent.  Selections, groupings, functions, joins
@@ -184,7 +184,7 @@ How the SQL gets made
184 184
 ---------------------
185 185
 
186 186
 The first thing I started with is the QueryCompiler and the data structures it
187  
-uses.  It takes the data structures from peewee and spits out SQL.  It works 
  187
+uses.  It takes the data structures from peewee and spits out SQL.  It works
188 188
 recursively and knows about a few types of expressions:
189 189
 
190 190
 * the query tree

0 notes on commit 105247d

Please sign in to comment.
Something went wrong with that request. Please try again.