Skip to content

Commit

Permalink
Disallow reserved words for identifiers (#5)
Browse files Browse the repository at this point in the history
Table and column names may not use reserved words. This does not
included SQL standard defined non-reserve words. Some of these words
are also parser keywords so they will return a different error, that's
OK, just as long as the name itself can not be used.
  • Loading branch information
elliotchance authored Jul 24, 2021
1 parent d063bdd commit 3d1c610
Show file tree
Hide file tree
Showing 8 changed files with 1,181 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ jobs:
with:
v-version: latest
id: v
- name: Verify fmt
run: v fmt -verify .
- name: Run SQL tests
run: v -stats test vsql
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ There are some types that are not supported yet:
| `SMALLINT` | f64 | Integer |
| `VARCHAR(n)` | string | Alias for `CHARACTER VARYING(n)` |

### Keywords

Names of entities (such as tables and columns) cannot be a
[reserved word](https://github.com/elliotchance/vsql/blob/main/vsql/keywords.v).

### SQLSTATE (Errors)

The error returned from `query()` will always one of the `SQLState` struct
Expand Down
2 changes: 1 addition & 1 deletion tests/errors.sql
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
TABLE
-- error: vsql.SQLState42601: syntax error at "TABLE"
-- error: vsql.SQLState42601: syntax error: at "TABLE"
Loading

0 comments on commit 3d1c610

Please sign in to comment.