@@ -38,7 +38,7 @@ await AccountMgr.select_custom_fields(
3838 " extend ->> '$.last_login.start_datetime' start_datetime" ,
3939 " CAST(extend ->> '$.last_login.online_sec' AS SIGNED) online_sec"
4040 ],
41- wheres = f " id IN ( { ' , ' .join(map (str , aids))} ) AND gender = 1 " , # These 4 ways of `wheres` can work equally
41+ wheres = f " id IN ( { ' ,' .join(map (str , aids))} ) AND gender= 1 " , # These 4 types of `wheres` are equal
4242 # wheres=Q(Q(id__in=aids), Q(gender=1), join_type="AND"),
4343 # wheres={"id__in": aids, "gender": 1},
4444 # wheres=[Q(id__in=aids), Q(gender=1)],
@@ -49,7 +49,7 @@ Generate sql and execute
4949 SELECT
5050 id, extend - >> ' $.last_login.ipv4' ipv4, extend - >> ' $.last_login.start_datetime' start_datetime, CAST(extend - >> ' $.last_login.online_sec' AS SIGNED) online_sec
5151 FROM account
52- WHERE ` id ` IN (1 ,2 ,3 ) AND ` gender` = 1
52+ WHERE id IN (1 ,2 ,3 ) AND gender= 1
5353```
5454
5555** complex example**
@@ -58,7 +58,7 @@ await AccountMgr.select_custom_fields(
5858 fields = [
5959 " locale" , " gender" , " COUNT(1) cnt"
6060 ],
61- wheres = " id BETWEEN 1 AND 12 " ,
61+ wheres = Q( id__range = [ 1 , 12 ]) ,
6262 groups = [" locale" , " gender" ],
6363 having = " cnt > 0" ,
6464 orders = [" locale" , " -gender" ],
@@ -70,7 +70,7 @@ Generate sql and execute
7070 SELECT
7171 locale, gender, COUNT (1 ) cnt
7272 FROM account
73- WHERE id BETWEEN 1 AND 12
73+ WHERE ` id ` BETWEEN 1 AND 12
7474 GROUP BY locale, gender
7575 HAVING cnt > 0
7676 ORDER BY locale ASC , gender DESC
@@ -89,14 +89,14 @@ await AccountMgr.upsert_json_field(
8989 },
9090 " $.uuid" : " fd04f7f2-24fc-4a73-a1d7-b6e99a464c5f" ,
9191 },
92- wheres = f " id = 8 " ,
92+ wheres = Q( id = 8 ) ,
9393)
9494```
9595Generate sql and execute
9696``` sql
9797 UPDATE account
9898 SET extend = JSON_SET(COALESCE(extend, ' {}' ), ' $.last_login' , CAST(' {"ipv4": "209.182.101.161", "start_datetime": "2022-10-16 11:11:05", "online_sec": 4209}' AS JSON), ' $.uuid' , ' fd04f7f2-24fc-4a73-a1d7-b6e99a464c5f' )
99- WHERE id = 8
99+ WHERE ` id ` = 8
100100```
101101
102102### ** upsert_on_duplicated**
@@ -124,7 +124,7 @@ Generate sql and execute
124124### ** insert_into_select**
125125``` python
126126await AccountMgr.insert_into_select(
127- wheres = f " id IN ( 4, 5, 6) " ,
127+ wheres = Q( id__in = [ 4 , 5 , 6 ]) ,
128128 remain_fields = [" gender" , " locale" ],
129129 assign_field_dict = {
130130 " active" : False ,
@@ -139,7 +139,7 @@ Generate sql and execute
139139 (gender, locale, active, name, extend)
140140 SELECT gender, locale, False active, CONCAT(LEFT(name, 26 ), ' [NEW]' ) name, ' {}' extend
141141 FROM account
142- WHERE id IN (4 , 5 , 6 )
142+ WHERE ` id ` IN (4 ,5 , 6 )
143143```
144144
145145### ** bulk_update_with_fly_table**
@@ -161,6 +161,6 @@ Generate sql and execute
161161 VALUES
162162 ROW(7 , False, 1 ), ROW(15 , True, 0 )
163163 ) AS fly_table (id, active, gender)
164- ) tmp ON account .id = tmp .id
165- SET account .active = tmp .active , account .gender = tmp .gender
164+ ) tmp ON account .id = tmp .id
165+ SET account .active = tmp .active , account .gender = tmp .gender
166166```
0 commit comments