Skip to content

Commit

Permalink
Merge branch 'master' into refactor-formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
mattn authored Dec 20, 2023
2 parents bf3093f + a9a7705 commit 77f1bc1
Show file tree
Hide file tree
Showing 74 changed files with 3,883 additions and 625 deletions.
19 changes: 6 additions & 13 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,17 @@ jobs:
goreleaser:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v3
with:
fetch-depth: 0
-
name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15
-
name: Run GoReleaser(xcgo) Snapshot
go-version: 1.18
- name: Run GoReleaser(xcgo) Snapshot
run: |
make snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
-
name: Run GoReleaser(xcgo) Publish
- name: Run GoReleaser(xcgo) Publish
if: startsWith(github.ref, 'refs/tags/v')
run: |
make publish
Expand Down
22 changes: 7 additions & 15 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,16 @@ on:

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
go-version:
- 1.13.x
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Go
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: ${{ matrix.go-version }}
- name: Checkout
uses: actions/checkout@v2
- name: Install golangci-lint
run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.23.6
go-version: 1.18
- name: Lint
run: /home/runner/go/bin/golangci-lint run
uses: golangci/golangci-lint-action@v3
with:
version: v1.45.2
- name: Test
run: go test -coverprofile coverage.out -covermode atomic ./...
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
run:
tests: false
timeout: 5m
linters:
disable:
- maligned
Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ changelog:
- '^test:'
release:
github:
owner: lighttiger2505
owner: sqls-server
name: sqls
# If set to auto, will mark the release as not ready for production
# in case there is an indicator for this in the tag e.g. v1.0.0-rc1
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ stringer:
.PHONY: snapshot
snapshot: $(SRCS)
docker run --rm --privileged \
-v ${PWD}:/go/src/github.com/lighttiger2505/sqls \
-v ${PWD}:/go/src/github.com/sqls-server/sqls \
-v /var/run/docker.sock:/var/run/docker.sock \
-w /go/src/github.com/lighttiger2505/sqls \
-w /go/src/github.com/sqls-server/sqls \
mailchain/goreleaser-xcgo --snapshot --rm-dist

.PHONY: publish
publish: $(SRCS)
docker run --rm --privileged \
-e GITHUB_TOKEN=$(GITHUB_TOKEN) \
-v ${PWD}:/go/src/github.com/lighttiger2505/sqls \
-v ${PWD}:/go/src/github.com/sqls-server/sqls \
-v /var/run/docker.sock:/var/run/docker.sock \
-w /go/src/github.com/lighttiger2505/sqls \
-w /go/src/github.com/sqls-server/sqls \
mailchain/goreleaser-xcgo --rm-dist
61 changes: 43 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# sqls

![test](https://github.com/lighttiger2505/sqls/workflows/test/badge.svg)
![test](https://github.com/sqls-server/sqls/workflows/test/badge.svg)

An implementation of the Language Server Protocol for SQL.

Expand All @@ -15,8 +15,9 @@ sqls aims to provide advanced intelligence for you to edit sql in your own edito
### Support RDBMS

- MySQL([Go-MySQL-Driver](https://github.com/go-sql-driver/mysql))
- PostgreSQL([pq](https://github.com/lib/pq))
- 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))

### Language Server Features

Expand All @@ -33,10 +34,15 @@ 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

![join_completion](imgs/sqls-fk_joins.gif)

#### CodeAction

![code_actions](https://github.com/lighttiger2505/sqls.vim/blob/master/imgs/sqls_vim_demo.gif)
![code_actions](https://github.com/sqls-server/sqls.vim/blob/master/imgs/sqls_vim_demo.gif)

- [x] Execute SQL
- [ ] Explain SQL
Expand All @@ -57,15 +63,16 @@ sqls aims to provide advanced intelligence for you to edit sql in your own edito

## Installation

```
go get github.com/lighttiger2505/sqls
```shell
go install github.com/sqls-server/sqls@latest
```

## Editor Plugins

- [sqls.vim](https://github.com/lighttiger2505/sqls.vim)
- [sqls.vim](https://github.com/sqls-server/sqls.vim)
- [vscode-sqls](https://github.com/lighttiger2505/vscode-sqls)
- [sqls.nvim](https://github.com/nanotee/sqls.nvim)
- [Emacs LSP mode](https://emacs-lsp.github.io/lsp-mode/page/lsp-sqls/)

## DB Configuration

Expand Down Expand Up @@ -115,12 +122,12 @@ connections:
port: 22
user: sshuser
passPhrase: ssspass
privateKey: /home/lighttiger2505/.ssh/id_rsa
privateKey: /home/sqls-server/.ssh/id_rsa
```
### Workspace configuration Sample
* setting example with vim-lsp.
- setting example with vim-lsp.
```vim
if executable('sqls')
Expand Down Expand Up @@ -149,7 +156,7 @@ if executable('sqls')
endif
```

* setting example with coc.nvim.
- setting example with coc.nvim.

In `coc-settings.json` opened by `:CocConfig`

Expand All @@ -166,7 +173,7 @@ In `coc-settings.json` opened by `:CocConfig`
}
```

* setting example with [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig/blob/master/CONFIG.md#sqls).
- setting example with [nvim-lspconfig](https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#sqls).

```lua
require'lspconfig'.sqls.setup{
Expand All @@ -187,22 +194,40 @@ 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"```:
```
{
"show_diagnostics_count_in_view_status": true,
"clients": {
"sqls": {
"enabled": true,
"command": ["/path/to/sqls binary"],
"selector": "source.sql"
}
}
}
```

**I'm sorry. Please wait a little longer for other editor settings.**

### Configuration Params

The first setting in `connections` is the default connection.

| Key | Description |
|-------------|----------------------|
| ----------- | -------------------- |
| connections | Database connections |

### connections

`dataSourceName` takes precedence over the value set in `proto`, `user`, `passwd`, `host`, `port`, `dbName`, `params`.

| Key | Description |
|----------------|---------------------------------------------|
| -------------- | ------------------------------------------- |
| alias | Connection alias name. Optional. |
| driver | `mysql`, `postgresql`, `sqlite3`. Required. |
| dataSourceName | Data source name. |
Expand All @@ -219,7 +244,7 @@ The first setting in `connections` is the default connection.
#### sshConfig

| Key | Description |
|------------|-----------------------------|
| ---------- | --------------------------- |
| host | ssh host. Required. |
| port | ssh port. Required. |
| user | ssh user. Optional. |
Expand All @@ -230,15 +255,15 @@ The first setting in `connections` is the default connection.

See also.

- https://github.com/go-sql-driver/mysql#dsn-data-source-name
- https://godoc.org/github.com/lib/pq
- https://github.com/mattn/go-sqlite3#connection-string
- <https://github.com/go-sql-driver/mysql#dsn-data-source-name>
- <https://pkg.go.dev/github.com/jackc/pgx/v4>
- <https://github.com/mattn/go-sqlite3#connection-string>

## Contributors

This project exists thanks to all the people who contribute.
<a href="https://github.com/lighttiger2505/sqls/graphs/contributors">
<img src="https://contrib.rocks/image?repo=lighttiger2505/sqls" />
<a href="https://github.com/sqls-server/sqls/graphs/contributors">
<img src="https://contrib.rocks/image?repo=sqls-server/sqls" />
</a>

## Inspired
Expand Down
12 changes: 4 additions & 8 deletions ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package ast
import (
"strings"

"github.com/lighttiger2505/sqls/dialect"
"github.com/lighttiger2505/sqls/token"
"github.com/sqls-server/sqls/dialect"
"github.com/sqls-server/sqls/token"
)

type NodeType int
Expand Down Expand Up @@ -605,17 +605,13 @@ func (t *SQLToken) Render(opts *RenderOptions) string {
}

func renderSQLWord(v *token.SQLWord, opts *RenderOptions) string {
isIdentifer := false
if v.Kind == dialect.Unmatched {
isIdentifer = true
}

isIdentifer := v.Kind == dialect.Unmatched
if isIdentifer {
if opts.IdentiferQuated {
v.QuoteStyle = '`'
return v.String()
}
return v.NoQuateString()
return v.String()
} else {
// is keyword
if opts.LowerCase {
Expand Down
6 changes: 3 additions & 3 deletions ast/astutil/astutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"fmt"
"strings"

"github.com/lighttiger2505/sqls/ast"
"github.com/lighttiger2505/sqls/dialect"
"github.com/lighttiger2505/sqls/token"
"github.com/sqls-server/sqls/ast"
"github.com/sqls-server/sqls/dialect"
"github.com/sqls-server/sqls/token"
)

type NodeMatcher struct {
Expand Down
10 changes: 10 additions & 0 deletions dialect/keyword.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,8 @@ const (
DatabaseDriverMySQL56 DatabaseDriver = "mysql56"
DatabaseDriverPostgreSQL DatabaseDriver = "postgresql"
DatabaseDriverSQLite3 DatabaseDriver = "sqlite3"
DatabaseDriverMssql DatabaseDriver = "mssql"
DatabaseDriverOracle DatabaseDriver = "oracle"
)

func DataBaseKeywords(driver DatabaseDriver) []string {
Expand All @@ -401,6 +403,10 @@ func DataBaseKeywords(driver DatabaseDriver) []string {
return postgresql13Keywords
case DatabaseDriverSQLite3:
return sqliteKeywords
case DatabaseDriverMssql:
return mssqlKeywords
case DatabaseDriverOracle:
return oracleKeyWords
default:
return sqliteKeywords
}
Expand All @@ -420,6 +426,10 @@ func DataBaseFunctions(driver DatabaseDriver) []string {
return []string{}
case DatabaseDriverSQLite3:
return []string{}
case DatabaseDriverMssql:
return []string{}
case DatabaseDriverOracle:
return oracleReservedWords
default:
return []string{}
}
Expand Down
Loading

0 comments on commit 77f1bc1

Please sign in to comment.