Skip to content

Commit ae3073b

Browse files
committed
doc: lint error-diagnostics
1 parent 4cb4570 commit ae3073b

File tree

2 files changed

+110
-89
lines changed

2 files changed

+110
-89
lines changed

doc/error-diagnostics.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Error Diagnostics <!-- omit in toc -->
2+
3+
## Table of Contents <!-- omit in toc -->
4+
5+
- [API](#api)
6+
- [Error Types](#error-types)
7+
- [Misaligned Attributes](#misaligned-attributes)
8+
- [Invalid Object references](#invalid-object-references)
9+
- [Invalid Table reference in a View](#invalid-table-reference-in-a-view)
10+
- [Invalid foreign key](#invalid-foreign-key)
11+
- [Duplicate ID](#duplicate-id)
12+
- [Missconstructed column type](#missconstructed-column-type)
13+
14+
## API
15+
16+
Error diagnostics procedure is called like this
17+
18+
```js
19+
let output = ddl.errorMsgs(`dept
20+
col1
21+
"is this table or misaligned column?"`);
22+
```
23+
24+
It returns an array of the Error objects
25+
26+
```js
27+
function SyntaxError( message, from, to, severity ) {
28+
this.from = from;
29+
this.to = to;
30+
if( to == null )
31+
this.to = new Offset(from.line, from.depth+1);
32+
this.message = message;
33+
this.severity = severity; // warning or error
34+
if( severity == null )
35+
this.severity = 'error';
36+
}
37+
```
38+
39+
where error message offsets are structured as follows
40+
41+
```js
42+
function Offset( line, depth ) {
43+
this.line = line; // 0-based
44+
this.depth = depth; // 0-based
45+
}
46+
```
47+
48+
## Error Types
49+
50+
### Misaligned Attributes
51+
52+
Indentation refers to the spaces at the beginning of a code line. Where in most
53+
of the other other programming languages the indentation in code is for
54+
readability only, Quick SQL uses indentation to define Quick SQL tree/forest
55+
structure. Parent-child relationship in this tree is interpreted as ether table
56+
containing list of columns, or as 2 tables related with referential integrity
57+
key constraint.
58+
59+
Inconsistent indentation is detected, with the error message designed to resolve
60+
any confusion.
61+
62+
### Invalid Object references
63+
64+
#### Invalid Table reference in a View
65+
66+
Example:
67+
68+
```quicksql
69+
dept
70+
name
71+
72+
view customer_view customer
73+
```
74+
75+
Here the `customer` table (or view) is missing.
76+
77+
#### Invalid foreign key
78+
79+
Example:
80+
81+
```quicksql
82+
department
83+
name
84+
employee
85+
dept /fk dept
86+
```
87+
88+
Here the `dept` table (or view) is missing.
89+
90+
#### Duplicate ID
91+
92+
Since identity columns are generated by default, specifying them explicitly like
93+
this
94+
95+
```quicksql
96+
dept
97+
id
98+
```
99+
100+
would be diagnosed an error.
101+
102+
#### Missconstructed column type
103+
104+
Quick SQL also recognizes syntactically invalid column types like this
105+
106+
```quicksql
107+
dept
108+
name vc-200
109+
name vc0
110+
```

doc/error_diagnostics.md

Lines changed: 0 additions & 89 deletions
This file was deleted.

0 commit comments

Comments
 (0)