-
Notifications
You must be signed in to change notification settings - Fork 1
/
sqlx-data.json
726 lines (726 loc) · 20.6 KB
/
sqlx-data.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
{
"db": "PostgreSQL",
"0d975be07317c96c240828eb500835aec1505d98d5dfbe92b360194a11291fe5": {
"describe": {
"columns": [
{
"name": "username?",
"ordinal": 0,
"type_info": "Varchar"
},
{
"name": "profile_image?",
"ordinal": 1,
"type_info": "Varchar"
},
{
"name": "title!",
"ordinal": 2,
"type_info": "Varchar"
},
{
"name": "content?",
"ordinal": 3,
"type_info": "Varchar"
},
{
"name": "created_on!",
"ordinal": 4,
"type_info": "Timestamptz"
},
{
"name": "topic_name!",
"ordinal": 5,
"type_info": "Varchar"
},
{
"name": "votes!",
"ordinal": 6,
"type_info": "Int8"
},
{
"name": "user_id?",
"ordinal": 7,
"type_info": "Int4"
},
{
"name": "post_id!",
"ordinal": 8,
"type_info": "Int4"
}
],
"nullable": [
false,
true,
false,
true,
false,
false,
false,
false,
false
],
"parameters": {
"Left": [
"Int4",
"Int8",
"Int8",
"Int4",
"Int4",
"Text",
"Int4"
]
}
},
"query": "\n SELECT \n users.username AS \"username?\", \n users.profile_image AS \"profile_image?\",\n posts.title AS \"title!\", \n posts.content AS \"content?\", \n posts.created_on AS \"created_on!\", \n topics.topic_name AS \"topic_name!\", \n posts.votes AS \"votes!\",\n users.user_id AS \"user_id?\",\n posts.post_id as \"post_id!\"\n FROM posts\n LEFT JOIN users ON users.user_id = posts.author\n INNER JOIN topics ON topics.topic_id = posts.topic\n WHERE (\n $4 = 0 OR\n ($4 = 1 AND topics.topic_id = $5) OR\n ($4 = 2 AND topics.topic_name = $6) OR\n ($4 = 3 AND users.user_id = $7)\n )\n ORDER BY\n CASE WHEN $1 = 1 THEN posts.created_on END DESC, \n CASE WHEN $1 = 2 THEN posts.created_on END ASC, \n CASE WHEN $1 = 3 THEN posts.votes END DESC, \n CASE WHEN $1 = 4 THEN posts.votes END ASC\n LIMIT $2 OFFSET $3\n "
},
"0e94a44e02cc0b262364b7cc82c974221083746baf9594e440a359f3b67a1efe": {
"describe": {
"columns": [
{
"name": "user_a?",
"ordinal": 0,
"type_info": "Int4"
},
{
"name": "user_b?",
"ordinal": 1,
"type_info": "Int4"
}
],
"nullable": [
true,
true
],
"parameters": {
"Left": [
"Int4",
"Int4"
]
}
},
"query": "\n SELECT \n user_a AS \"user_a?\", \n user_b AS \"user_b?\"\n FROM conversations \n WHERE (user_a = $1 OR user_b = $1) AND (conversation_id = $2)\n "
},
"13453b5fcb0ce5990aa2b0071f55044c93c2503d842339d3a558338d046a335e": {
"describe": {
"columns": [
{
"name": "user_id",
"ordinal": 0,
"type_info": "Int4"
},
{
"name": "username",
"ordinal": 1,
"type_info": "Varchar"
},
{
"name": "email",
"ordinal": 2,
"type_info": "Varchar"
},
{
"name": "password_hash",
"ordinal": 3,
"type_info": "Varchar"
},
{
"name": "created_on",
"ordinal": 4,
"type_info": "Timestamptz"
},
{
"name": "last_activity",
"ordinal": 5,
"type_info": "Timestamptz"
},
{
"name": "user_role!: _",
"ordinal": 6,
"type_info": {
"Custom": {
"kind": {
"Enum": [
"banned",
"unverified",
"user",
"moderator",
"admin"
]
},
"name": "role_type"
}
}
},
{
"name": "token",
"ordinal": 7,
"type_info": "Varchar"
},
{
"name": "profile_image",
"ordinal": 8,
"type_info": "Varchar"
},
{
"name": "banner_image",
"ordinal": 9,
"type_info": "Varchar"
}
],
"nullable": [
false,
false,
false,
false,
false,
false,
false,
false,
true,
true
],
"parameters": {
"Left": [
"Text"
]
}
},
"query": "\n SELECT \n user_id, \n username, \n email, \n password_hash,\n created_on,\n last_activity,\n user_role AS \"user_role!: _\",\n token,\n profile_image,\n banner_image\n FROM users WHERE token = $1"
},
"27fb102c295929437e3fa5368fac1b5092bf096fbbfeb36634979aa5b3874a60": {
"describe": {
"columns": [
{
"name": "message_id",
"ordinal": 0,
"type_info": "Int4"
},
{
"name": "message_direction!: _",
"ordinal": 1,
"type_info": {
"Custom": {
"kind": {
"Enum": [
"a_to_b",
"b_to_a"
]
},
"name": "message_direction_type"
}
}
},
{
"name": "relative_message_direction?: _",
"ordinal": 2,
"type_info": {
"Custom": {
"kind": {
"Enum": [
"a_to_b",
"b_to_a"
]
},
"name": "message_direction_type"
}
}
},
{
"name": "content",
"ordinal": 3,
"type_info": "Varchar"
},
{
"name": "created_on",
"ordinal": 4,
"type_info": "Timestamptz"
},
{
"name": "edited",
"ordinal": 5,
"type_info": "Bool"
},
{
"name": "reply_to",
"ordinal": 6,
"type_info": "Int4"
},
{
"name": "reply_to_content?",
"ordinal": 7,
"type_info": "Varchar"
}
],
"nullable": [
false,
false,
null,
false,
false,
false,
true,
null
],
"parameters": {
"Left": [
"Int4",
"Int4"
]
}
},
"query": "\n SELECT \n message_id,\n message_direction AS \"message_direction!: _\",\n (\n CASE \n -- IF THE ID IS -1 OR NULL THEN SKIP AND RETURN null\n WHEN $2 = -1 THEN null\n WHEN $2 = null THEN null\n ELSE (\n CASE \n WHEN ( -- IF user_a IN conversations MATCHES user_id\n (\n SELECT user_a\n FROM conversations \n WHERE conversation_id = $1\n ) = $2 \n ) THEN ( -- THEN PUT message_direction AS-IS INTO relative_message_direction \n message_direction\n ) ELSE ( -- ELSE, INVERT IT\n CASE \n WHEN (message_direction = 'a_to_b') THEN 'b_to_a'::message_direction_type\n ELSE 'a_to_b'::message_direction_type\n END\n )\n END\n )\n END\n ) AS \"relative_message_direction?: _\",\n content,\n created_on,\n edited,\n reply_to,\n (\n SELECT content\n FROM messages AS msg\n WHERE msg.message_id = msg.reply_to\n LIMIT 1\n ) as \"reply_to_content?\"\n FROM messages\n WHERE conversation_id = $1\n "
},
"31e5bf824f5e963f4decbdf5648647a4fbb123fd1c9d0b9ae5d6aafa78fb2d18": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Left": [
"Int4"
]
}
},
"query": "DELETE FROM conversations WHERE (user_a = $1) OR (user_b = $1)"
},
"34925f740a4cea7187f33f989ebd1841a9a048a4df143581e9663ea496854442": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Left": [
"Int4"
]
}
},
"query": "DELETE FROM comments WHERE author = $1"
},
"371777ab4ca69dd66f07d227d8f33c5f8ac4f4d10b1b9023b2f725e3d8e52022": {
"describe": {
"columns": [
{
"name": "vote_id",
"ordinal": 0,
"type_info": "Int4"
},
{
"name": "vote",
"ordinal": 1,
"type_info": "Bool"
}
],
"nullable": [
false,
false
],
"parameters": {
"Left": [
"Int4",
"Int4"
]
}
},
"query": "SELECT vote_id, vote FROM votes WHERE user_id = $1 AND post_id = $2"
},
"601fa9e07a9e1d335e8f7880bb9136007fe3ab3ef6abbf1904d9b9013ec92825": {
"describe": {
"columns": [
{
"name": "username?",
"ordinal": 0,
"type_info": "Varchar"
},
{
"name": "profile_image",
"ordinal": 1,
"type_info": "Varchar"
},
{
"name": "title",
"ordinal": 2,
"type_info": "Varchar"
},
{
"name": "content",
"ordinal": 3,
"type_info": "Varchar"
},
{
"name": "created_on",
"ordinal": 4,
"type_info": "Timestamptz"
},
{
"name": "topic_name",
"ordinal": 5,
"type_info": "Varchar"
},
{
"name": "votes",
"ordinal": 6,
"type_info": "Int8"
},
{
"name": "user_id?",
"ordinal": 7,
"type_info": "Int4"
},
{
"name": "post_id",
"ordinal": 8,
"type_info": "Int4"
}
],
"nullable": [
false,
true,
false,
true,
false,
false,
false,
false,
false
],
"parameters": {
"Left": [
"Int4"
]
}
},
"query": "\n SELECT \n users.username AS \"username?\", \n users.profile_image AS profile_image,\n posts.title AS title, \n posts.content AS content, \n posts.created_on AS created_on, \n topics.topic_name AS topic_name, \n posts.votes AS votes,\n users.user_id AS \"user_id?\",\n posts.post_id as post_id\n FROM posts\n LEFT JOIN users ON users.user_id = posts.author\n INNER JOIN topics ON topics.topic_id = posts.topic\n WHERE posts.post_id = $1\n ORDER BY votes DESC\n "
},
"a2c1a5d5c06ebd672b6d5010f0483eecc1ac8ff7e01fb4363c5ec538788a1932": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Left": [
"Int4"
]
}
},
"query": "DELETE FROM posts WHERE author = $1"
},
"a90b5707c128cc1e29a60086b7b5a2ecaa6f9edcf9d430a3208c6f818a03a2c6": {
"describe": {
"columns": [
{
"name": "message_id",
"ordinal": 0,
"type_info": "Int4"
}
],
"nullable": [
false
],
"parameters": {
"Left": [
"Int4",
"Int4",
"Varchar",
"Int4"
]
}
},
"query": "\n INSERT INTO messages (\n message_direction,\n conversation_id,\n content,\n reply_to\n ) VALUES (\n CASE \n WHEN (\n (\n SELECT user_a\n FROM conversations \n WHERE conversation_id = $2\n ) = $1 \n ) THEN 'a_to_b'::message_direction_type\n ELSE 'b_to_a'::message_direction_type\n END,\n $2,\n $3,\n $4\n ) RETURNING message_id\n "
},
"c660dbe0e1cab173d68cfc00d0df19d8c753da3931e8f9327773d17151e72999": {
"describe": {
"columns": [
{
"name": "conversation_id",
"ordinal": 0,
"type_info": "Int4"
},
{
"name": "user_id?",
"ordinal": 1,
"type_info": "Int4"
},
{
"name": "user_username?",
"ordinal": 2,
"type_info": "Varchar"
},
{
"name": "user_profile_image?",
"ordinal": 3,
"type_info": "Varchar"
},
{
"name": "last_message?",
"ordinal": 4,
"type_info": "Text"
}
],
"nullable": [
false,
false,
false,
true,
null
],
"parameters": {
"Left": [
"Int4",
"Int4"
]
}
},
"query": "\n SELECT\n conversations.conversation_id,\n users.user_id AS \"user_id?\",\n users.username AS \"user_username?\",\n users.profile_image AS \"user_profile_image?\",\n null AS \"last_message?\"\n FROM conversations\n LEFT JOIN users\n ON users.user_id = (\n CASE WHEN \n conversations.user_a = $1 \n THEN \n conversations.user_b\n ELSE \n conversations.user_a \n END\n )\n WHERE (user_a = $1 OR user_b = $1) AND (conversation_id = $2)\n "
},
"cb027e1383cee8690556a9def0c73ef43f9a1acb4720779b1e1db2d00cb19da0": {
"describe": {
"columns": [
{
"name": "users",
"ordinal": 0,
"type_info": "Int4"
},
{
"name": "posts",
"ordinal": 1,
"type_info": "Int4"
}
],
"nullable": [
false,
false
],
"parameters": {
"Left": []
}
},
"query": "SELECT * FROM stats"
},
"cbaf6c4dca345fcaf1ccd25826d490c7ce3c78c379383932a0caa358a98d6777": {
"describe": {
"columns": [
{
"name": "conversation_id",
"ordinal": 0,
"type_info": "Int4"
},
{
"name": "user_id?",
"ordinal": 1,
"type_info": "Int4"
},
{
"name": "user_username?",
"ordinal": 2,
"type_info": "Varchar"
},
{
"name": "user_profile_image?",
"ordinal": 3,
"type_info": "Varchar"
},
{
"name": "last_message?",
"ordinal": 4,
"type_info": "Varchar"
}
],
"nullable": [
false,
false,
false,
true,
null
],
"parameters": {
"Left": [
"Int4"
]
}
},
"query": "\n SELECT \n conversations.conversation_id,\n users.user_id AS \"user_id?\",\n users.username AS \"user_username?\",\n users.profile_image AS \"user_profile_image?\",\n (\n SELECT content\n FROM messages AS msg\n WHERE msg.conversation_id = conversations.conversation_id\n ORDER BY msg.created_on DESC\n LIMIT 1\n ) as \"last_message?\"\n FROM conversations\n LEFT JOIN users \n ON users.user_id = (\n CASE WHEN \n conversations.user_a = $1 \n THEN \n conversations.user_b\n ELSE \n conversations.user_a \n END\n )\n WHERE (user_a = $1 OR user_b = $1)\n "
},
"d9410724d50c92132dc8732f95d3000a2719936ef0537ce6a9818dc5e358be5f": {
"describe": {
"columns": [
{
"name": "user_id",
"ordinal": 0,
"type_info": "Int4"
},
{
"name": "username",
"ordinal": 1,
"type_info": "Varchar"
},
{
"name": "email",
"ordinal": 2,
"type_info": "Varchar"
},
{
"name": "password_hash",
"ordinal": 3,
"type_info": "Varchar"
},
{
"name": "created_on",
"ordinal": 4,
"type_info": "Timestamptz"
},
{
"name": "last_activity",
"ordinal": 5,
"type_info": "Timestamptz"
},
{
"name": "user_role!: _",
"ordinal": 6,
"type_info": {
"Custom": {
"kind": {
"Enum": [
"banned",
"unverified",
"user",
"moderator",
"admin"
]
},
"name": "role_type"
}
}
},
{
"name": "token",
"ordinal": 7,
"type_info": "Varchar"
},
{
"name": "profile_image",
"ordinal": 8,
"type_info": "Varchar"
},
{
"name": "banner_image",
"ordinal": 9,
"type_info": "Varchar"
}
],
"nullable": [
false,
false,
false,
false,
false,
false,
false,
false,
true,
true
],
"parameters": {
"Left": [
"Int4"
]
}
},
"query": "\n SELECT \n user_id, \n username, \n email, \n password_hash,\n created_on,\n last_activity,\n user_role AS \"user_role!: _\",\n token,\n profile_image,\n banner_image\n FROM users WHERE user_id = $1"
},
"e48f3e034a0d887b66e4d9ddf6e6aef8713decd52b8a7048e622ef74a07cef01": {
"describe": {
"columns": [
{
"name": "message_id",
"ordinal": 0,
"type_info": "Int4"
},
{
"name": "message_direction!: _",
"ordinal": 1,
"type_info": {
"Custom": {
"kind": {
"Enum": [
"a_to_b",
"b_to_a"
]
},
"name": "message_direction_type"
}
}
},
{
"name": "relative_message_direction?: _",
"ordinal": 2,
"type_info": "Text"
},
{
"name": "content",
"ordinal": 3,
"type_info": "Varchar"
},
{
"name": "created_on",
"ordinal": 4,
"type_info": "Timestamptz"
},
{
"name": "edited",
"ordinal": 5,
"type_info": "Bool"
},
{
"name": "reply_to",
"ordinal": 6,
"type_info": "Int4"
},
{
"name": "reply_to_content?",
"ordinal": 7,
"type_info": "Varchar"
}
],
"nullable": [
false,
false,
null,
false,
false,
false,
true,
null
],
"parameters": {
"Left": [
"Int4"
]
}
},
"query": "\n SELECT \n message_id,\n message_direction AS \"message_direction!: _\",\n null AS \"relative_message_direction?: _\",\n content,\n created_on,\n edited,\n reply_to,\n (\n SELECT content\n FROM messages AS msg\n WHERE msg.message_id = msg.reply_to\n LIMIT 1\n ) as \"reply_to_content?\"\n FROM messages\n WHERE message_id = $1\n "
},
"f2329f313bc1af2a88d3432347bff12afdfee729deea0213ad6090b7ecae6f25": {
"describe": {
"columns": [
{
"name": "password_hash",
"ordinal": 0,
"type_info": "Varchar"
},
{
"name": "token",
"ordinal": 1,
"type_info": "Varchar"
}
],
"nullable": [
false,
false
],
"parameters": {
"Left": [
"Text"
]
}
},
"query": "SELECT password_hash, token FROM users WHERE email = $1"
}
}