summaryrefslogtreecommitdiffstats
path: root/test/test_sql_anno.sh
blob: e09c3125f5dade0566c860eb82639a7e954f225a (plain)
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
#! /bin/bash

# basic query
run_cap_test ./drive_sql_anno "SELECT * FROM FOO"

# no help for keyword flag
run_cap_test ./drive_sql_anno "TABLE"

# nested function calls
run_cap_test ./drive_sql_anno "SELECT foo(bar())"

# nested function calls
run_cap_test ./drive_sql_anno "SELECT foo(bar())" 2

# caret in keyword whitespace
run_cap_test ./drive_sql_anno "SELECT       lower(abc)" 9

# caret in function whitespace
run_cap_test ./drive_sql_anno "SELECT lower(   abc    )" 14

# caret in unfinished function call
run_cap_test ./drive_sql_anno "SELECT lower(abc" 16

# caret on the outer function
run_cap_test ./drive_sql_anno "SELECT instr(lower(abc), '123')" 9

# caret on a nested function
run_cap_test ./drive_sql_anno "SELECT instr(lower(abc), '123')" 15

# caret on a flag
run_cap_test ./drive_sql_anno "SELECT instr(lower(abc), '123') FROM bar" 30

# multiple help hits
run_cap_test ./drive_sql_anno "CREATE" 2

# string vs ident
run_cap_test ./drive_sql_anno "SELECT 'hello, world!' FROM \"my table\""

# math
run_cap_test ./drive_sql_anno "SELECT (1 + 2) AS three"

run_cap_test ./drive_sql_anno "SELECT (1.5 + 2.2) AS decim"

# subqueries
run_cap_test ./drive_sql_anno "SELECT * FROM (SELECT foo, bar FROM baz)"

run_cap_test ./drive_sql_anno \
   "SELECT * from vmw_log, regexp_capture(log_body, '--> /SessionStats/SessionPool/Session/(?<line>[abc]+)')"

run_cap_test ./drive_sql_anno "SELECT * FROM foo.bar"