Skip to content

Commit

Permalink
Merge branch 'fix-typo-quote' into line-break
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn committed Dec 30, 2023
2 parents cc18533 + 9006a82 commit 10d2962
Show file tree
Hide file tree
Showing 21 changed files with 1,415 additions and 110 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ sqls aims to provide advanced intelligence for you to edit sql in your own edito
- PostgreSQL([pgx](https://github.com/jackc/pgx))
- SQLite3([go-sqlite3](https://github.com/mattn/go-sqlite3))
- MSSQL([go-mssqldb](https://github.com/denisenkom/go-mssqldb))
- H2([pgx](https://github.com/CodinGame/h2go))
- Vertica([vertica-sql-go](https://github.com/vertica/vertica-sql-go))

### Language Server Features

Expand All @@ -34,7 +36,7 @@ sqls aims to provide advanced intelligence for you to edit sql in your own edito
- DDL(Data Definition Language)
- [ ] CREATE TABLE
- [ ] ALTER TABLE

#### Join completion
If the tables are connected with a foreign key sqls can complete ```JOIN``` statements

Expand Down Expand Up @@ -123,6 +125,9 @@ connections:
user: sshuser
passPhrase: ssspass
privateKey: /home/sqls-server/.ssh/id_rsa
- alias: dsn_vertica
driver: vertica
dataSourceName: vertica://user:pass@host:5433/dbname
```
### Workspace configuration Sample
Expand Down Expand Up @@ -195,9 +200,9 @@ require'lspconfig'.sqls.setup{
```

- Setting example for Sublime Text 4

Install the LSP Client by Opening the command palette and run ```Package Control: Install Package```, then select ```LSP```.

Open ```Preferences > Package Settings > LSP > Settings``` and add the ```"sqls"``` client configuration to the ```"clients"```:
```
{
Expand Down Expand Up @@ -229,7 +234,7 @@ The first setting in `connections` is the default connection.
| Key | Description |
| -------------- | ------------------------------------------- |
| alias | Connection alias name. Optional. |
| driver | `mysql`, `postgresql`, `sqlite3`. Required. |
| driver | `mysql`, `postgresql`, `sqlite3`, `mssql`, `h2`. Required. |
| dataSourceName | Data source name. |
| proto | `tcp`, `udp`, `unix`. |
| user | User name |
Expand Down
14 changes: 7 additions & 7 deletions ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const (

type RenderOptions struct {
LowerCase bool
IdentifierQuated bool
IdentifierQuoted bool
}

type Node interface {
Expand Down Expand Up @@ -67,7 +67,7 @@ func NewItem(tok *token.Token) Node {
return &Item{NewSQLToken(tok)}
}
func (i *Item) String() string { return i.Tok.String() }
func (i *Item) NoQuateString() string { return i.Tok.NoQuateString() }
func (i *Item) NoQuoteString() string { return i.Tok.NoQuoteString() }
func (i *Item) Render(opts *RenderOptions) string { return i.Tok.Render(opts) }
func (i *Item) Type() NodeType { return TypeItem }
func (i *Item) GetToken() *SQLToken { return i.Tok }
Expand Down Expand Up @@ -241,11 +241,11 @@ func (i *Identifier) String() string { return i.Tok.String() }
func (i *Identifier) Render(opts *RenderOptions) string {
tmpOpts := &RenderOptions{
LowerCase: false,
IdentifierQuated: opts.IdentifierQuated,
IdentifierQuoted: opts.IdentifierQuoted,
}
return i.Tok.Render(tmpOpts)
}
func (i *Identifier) NoQuateString() string { return i.Tok.NoQuateString() }
func (i *Identifier) NoQuoteString() string { return i.Tok.NoQuoteString() }
func (i *Identifier) GetToken() *SQLToken { return i.Tok }
func (i *Identifier) Pos() token.Pos { return i.Tok.From }
func (i *Identifier) End() token.Pos { return i.Tok.To }
Expand Down Expand Up @@ -529,10 +529,10 @@ func (t *SQLToken) String() string {
}
}

func (t *SQLToken) NoQuateString() string {
func (t *SQLToken) NoQuoteString() string {
switch v := t.Value.(type) {
case *token.SQLWord:
return v.NoQuateString()
return v.NoQuoteString()
case string:
if t.Kind == token.Comment {
return "--" + v
Expand Down Expand Up @@ -566,7 +566,7 @@ func (t *SQLToken) Render(opts *RenderOptions) string {
func renderSQLWord(v *token.SQLWord, opts *RenderOptions) string {
isIdentifier := v.Kind == dialect.Unmatched
if isIdentifier {
if opts.IdentifierQuated {
if opts.IdentifierQuoted {
v.QuoteStyle = '`'
return v.String()
}
Expand Down
107 changes: 107 additions & 0 deletions dialect/h2.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
package dialect

var h2Keywords = []string{
"ALL",
"AND",
"ANY",
"ARRAY",
"AS",
"ASYMMETRIC",
"AUTHORIZATION",
"BETWEEN",
"BOTH",
"CASE",
"CAST",
"CHECK",
"CONSTRAINT",
"CROSS",
"CURRENT_CATALOG",
"CURRENT_DATE",
"CURRENT_PATH",
"CURRENT_ROLE",
"CURRENT_SCHEMA",
"CURRENT_TIME",
"CURRENT_TIMESTAMP",
"CURRENT_USER",
"DAY",
"DEFAULT",
"DISTINCT",
"ELSE",
"END",
"EXCEPT",
"EXISTS",
"FALSE",
"FETCH",
"FILTER",
"FOR",
"FOREIGN",
"FROM",
"FULL",
"GROUP",
"GROUPS",
"HAVING",
"HOUR",
"IF",
"ILIKE",
"IN",
"INNER",
"INTERSECT",
"INTERVAL",
"IS",
"JOIN",
"KEY",
"LEADING",
"LEFT",
"LIKE",
"LIMIT",
"LOCALTIME",
"LOCALTIMESTAMP",
"MINUS",
"MINUTE",
"MONTH",
"NATURAL",
"NOT",
"NULL",
"OFFSET",
"ON",
"OR",
"ORDER",
"OVER",
"PARTITION",
"PRIMARY",
"QUALIFY",
"RANGE",
"REGEXP",
"RIGHT",
"ROW",
"ROWNUM",
"ROWS",
"SECOND",
"SELECT",
"SESSION_USER",
"SET",
"SOME",
"SYMMETRIC",
"SYSTEM_USER",
"TABLE",
"TO",
"TOP",
"CS",
"TRAILING",
"TRUE",
"UESCAPE",
"UNION",
"UNIQUE",
"UNKNOWN",
"USER",
"USING",
"VALUE",
"VALUES",
"WHEN",
"WHERE",
"WINDOW",
"WITH",
"YEAR",
"_ROWID_",
}

8 changes: 8 additions & 0 deletions dialect/keyword.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ const (
DatabaseDriverSQLite3 DatabaseDriver = "sqlite3"
DatabaseDriverMssql DatabaseDriver = "mssql"
DatabaseDriverOracle DatabaseDriver = "oracle"
DatabaseDriverH2 DatabaseDriver = "h2"
DatabaseDriverVertica DatabaseDriver = "vertica"
)

func DataBaseKeywords(driver DatabaseDriver) []string {
Expand All @@ -407,6 +409,10 @@ func DataBaseKeywords(driver DatabaseDriver) []string {
return mssqlKeywords
case DatabaseDriverOracle:
return oracleKeyWords
case DatabaseDriverH2:
return h2Keywords
case DatabaseDriverVertica:
return verticaKeywords
default:
return sqliteKeywords
}
Expand All @@ -430,6 +436,8 @@ func DataBaseFunctions(driver DatabaseDriver) []string {
return []string{}
case DatabaseDriverOracle:
return oracleReservedWords
case DatabaseDriverVertica:
return verticaReservedWords
default:
return []string{}
}
Expand Down
Loading

0 comments on commit 10d2962

Please sign in to comment.