|
21 | 21 | {text: "name", displayText: "name | The name"}]
|
22 | 22 | }];
|
23 | 23 |
|
| 24 | + var displayTextTablesWithDefault = [ |
| 25 | + { |
| 26 | + text: "Api__TokenAliases", |
| 27 | + columns: [ |
| 28 | + { |
| 29 | + text: "token", |
| 30 | + displayText: "token | varchar(255) | Primary", |
| 31 | + columnName: "token", |
| 32 | + columnHint: "varchar(255) | Primary" |
| 33 | + }, |
| 34 | + { |
| 35 | + text: "alias", |
| 36 | + displayText: "alias | varchar(255) | Primary", |
| 37 | + columnName: "alias", |
| 38 | + columnHint: "varchar(255) | Primary" |
| 39 | + } |
| 40 | + ] |
| 41 | + }, |
| 42 | + { |
| 43 | + text: "mytable", |
| 44 | + columns: [ |
| 45 | + { text: "id", displayText: "id | Unique ID" }, |
| 46 | + { text: "name", displayText: "name | The name" } |
| 47 | + ] |
| 48 | + } |
| 49 | + ]; |
| 50 | + |
24 | 51 | namespace = "sql-hint_";
|
25 | 52 |
|
26 | 53 | function test(name, spec) {
|
27 | 54 | testCM(name, function(cm) {
|
28 | 55 | cm.setValue(spec.value);
|
29 | 56 | cm.setCursor(spec.cursor);
|
30 |
| - var completion = CodeMirror.hint.sql(cm, {tables: spec.tables}); |
| 57 | + var completion = CodeMirror.hint.sql(cm, { |
| 58 | + tables: spec.tables, |
| 59 | + defaultTable: spec.defaultTable, |
| 60 | + disableKeywords: spec.disableKeywords |
| 61 | + }); |
31 | 62 | if (!deepCompare(completion.list, spec.list))
|
32 | 63 | throw new Failure("Wrong completion results " + JSON.stringify(completion.list) + " vs " + JSON.stringify(spec.list));
|
33 | 64 | eqCharPos(completion.from, spec.from);
|
|
46 | 77 | to: Pos(0, 3)
|
47 | 78 | });
|
48 | 79 |
|
| 80 | + test("keywords_disabled", { |
| 81 | + value: "SEL", |
| 82 | + cursor: Pos(0, 3), |
| 83 | + disableKeywords: true, |
| 84 | + list: [], |
| 85 | + from: Pos(0, 0), |
| 86 | + to: Pos(0, 3) |
| 87 | + }); |
| 88 | + |
49 | 89 | test("from", {
|
50 | 90 | value: "SELECT * fr",
|
51 | 91 | cursor: Pos(0, 11),
|
|
185 | 225 | mode: "text/x-sqlite"
|
186 | 226 | });
|
187 | 227 |
|
| 228 | + test("displayText_default_table", { |
| 229 | + value: "SELECT a", |
| 230 | + cursor: Pos(0, 8), |
| 231 | + disableKeywords: true, |
| 232 | + defaultTable: "Api__TokenAliases", |
| 233 | + tables: displayTextTablesWithDefault, |
| 234 | + list: [ |
| 235 | + { |
| 236 | + text: "alias", |
| 237 | + displayText: "alias | varchar(255) | Primary", |
| 238 | + columnName: "alias", |
| 239 | + columnHint: "varchar(255) | Primary", |
| 240 | + className: "CodeMirror-hint-table CodeMirror-hint-default-table" |
| 241 | + }, |
| 242 | + { text: "Api__TokenAliases", className: "CodeMirror-hint-table" } |
| 243 | + ], |
| 244 | + from: Pos(0, 7), |
| 245 | + to: Pos(0, 8) |
| 246 | + }); |
| 247 | + |
188 | 248 | test("displayText_table", {
|
189 | 249 | value: "SELECT myt",
|
190 | 250 | cursor: Pos(0, 10),
|
|
0 commit comments