-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgsb_common_sql.go
More file actions
74 lines (62 loc) · 2.9 KB
/
gsb_common_sql.go
File metadata and controls
74 lines (62 loc) · 2.9 KB
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
package go_sqlite_bench
import _ "embed"
const LoremIpsum = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis eget sapien accumsan, commodo ligula iaculis, pretium ligula. In ac lobortis nulla. Donec lobortis metus sed mauris iaculis euismod. Ut vehicula velit vitae dolor maximus euismod. Nulla vel risus eros. Vivamus porttitor odio eleifend, imperdiet tellus sed, feugiat augue. Donec faucibus eget nunc facilisis gravida. Fusce posuere ac lacus eu rutrum. Vivamus nec nibh sed nisl maximus varius. Pellentesque in placerat eros. Vivamus efficitur in dolor nec eleifend. Proin quis nibh quis enim rutrum posuere. Aliquam odio metus, scelerisque quis massa imperdiet, tincidunt placerat orci. Maecenas posuere, ex vitae porttitor tristique, risus erat bibendum augue, nec tempus eros dolor vitae ipsum.`
const LoremIpsumJSON = `{"lorem": 10, "ipsum": {"dolor": 100, "sit": 1000}}`
var SQLForSchema = []string{
`
create table posts (
id integer primary key,
title text not null,
content text not null,
created text not null default (strftime('%Y-%m-%dT%H:%M:%SZ')),
stats text not null
);
`,
`
create index post_title_idx on posts (title);
`,
`
create index post_created_idx on posts (created);
`,
`
create table comments (
id integer primary key,
post_id int not null references posts (id)
on update restrict
on delete cascade,
name text not null,
content text not null,
created text not null default (strftime('%Y-%m-%dT%H:%M:%SZ')),
stats text not null
);
`,
`
create index comment_post_id_idx on comments (post_id);
`,
`
create index comment_post_id_created_idx on comments (post_id, created);
`,
`
create index comment_created_idx on comments (created);
`,
}
const SQLForCountPosts = `SELECT COUNT(*) FROM posts`
const SQLForCountComments = `SELECT COUNT(*) FROM comments`
const SQLForInsertPost = `INSERT INTO posts (title, content, stats) VALUES (?1, ?2, ?3)`
const SQLForInsertPostWithCreated = `INSERT INTO posts (title, content, stats, created) VALUES (?1, ?2, ?3, ?4)`
const SQLForInsertComment = `INSERT INTO comments (post_id, name, content, stats) VALUES (?1, ?2, ?3, ?4)`
const SQLForInsertCommentWithCreated = `INSERT INTO comments (post_id, name, content, stats, created) VALUES (?1, ?2, ?3, ?4, ?5)`
const SQLForSelectPostByID = `SELECT title, content, created, stats FROM posts WHERE id = ?1`
const SQLForSelectCommentsByPostID = `SELECT id, name, content, created, stats FROM comments WHERE post_id = ?1 ORDER BY created`
//go:embed gsb_common_sql_query_correlated.sql
var SQLForQueryCorrelated string
//go:embed gsb_common_sql_query_groupby.sql
var SQLForQueryGroupBy string
//go:embed gsb_common_sql_query_json.sql
var SQLForQueryJSON string
//go:embed gsb_common_sql_query_orderby.sql
var SQLForQueryOrderBy string
//go:embed gsb_common_sql_query_recursivecte.sql
var SQLForQueryRecursiveCTE string
//go:embed gsb_common_sql_query_window.sql
var SQLForQueryWindow string