Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring to use Syntax Tree #18

Merged
merged 6 commits into from
Oct 19, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add
  • Loading branch information
Satoshi MATSUZAKI committed Oct 15, 2019
commit 0edfa4988c7a0dd681dc497660ecd5e3f4535c4b
23 changes: 11 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,28 @@ sqlint/tests/data/query001.sql:(L7, 6): comma must be head of line

## Checking variations

check all following variations in default
Check if sql statement violates following rules.

- indent steps are N multiples.(default: N = 4)
- indent steps are N multiples (default: N = 4).

- duplicated spaces.
- duplicated whitespaces except indent.

- duplicated blank lines.

- reserved keywords is capital or not (default: not capital).
- reserved keywords is capital case or not (default: not capital).

- comma is head(end) of the line which connect some columns or conditions. (default: head)
- comma is head(or end) of the line which connects some columns or conditions (default: head).

- a whitespace are not before `)` or after `(`.

- white-spaces are not before ) or after (
- a whitespace is before and after binary operators.
- (e.g.) `=`, `<`, `>`, `<=`. `>=`. `<>`, `!=`, `+`, `-`, `*`, `/`, `%`

- a whitespace is before and after binary operators
- (e.g.) =, <, >, <=. >=. <>, !=, +, -, *, /, %
- the table name is at the same line as join context.

- the table name is at the same line as join context
- join contexts are written fully, for example `left outer join, `inner join or `cross join`.

- join context is [left outer join], [inner join] or [cross join]

- indent before 'on', 'or', 'and' (except between a and b)
- whether new line starts at 'on', 'or', 'and' context (except `between`).

## Futures
- table_name alias doesn't equal reserved functions
Expand Down
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ def _requirements():
long_description = ''

# read __init__
with open(path.join(root_dir, 'sqlint', '__init__.py')) as f:
with open(path.join(root_dir, 'src', '__init__.py')) as f:
init_text = f.read()
version = re.search(r'__version__\s*=\s*[\'\"](.+?)[\'\"]', init_text).group(1)
assert version

setup(
name='sqlint',
name='src',
version=version,
license="MIT",
author='shigeru',
Expand All @@ -50,7 +50,7 @@ def _requirements():
],
entry_points={
"console_scripts": [
'sqlint=sqlint.__main__:main',
'sqlint=src.__main__:main',
]
}
)
9 changes: 0 additions & 9 deletions sqlint/__main__.py

This file was deleted.

13 changes: 0 additions & 13 deletions sqlint/parser/__init__.py

This file was deleted.

166 changes: 0 additions & 166 deletions sqlint/parser/parser.py

This file was deleted.

26 changes: 0 additions & 26 deletions sqlint/parser/token.py

This file was deleted.

13 changes: 6 additions & 7 deletions sqlint/__init__.py → src/__init__.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
# -*- coding: utf-8 -*-

from sqlint import sqlint
from .checker.old import check

__version__ = '0.1.2'

__all__ = [
'sqlint'
'check'
]


'''
def parse(stmt):
"""

:param stmt:
:return:
"""

return sqlint.parse(stmt)
return api.parse(stmt)


def check(stmt):
Expand All @@ -26,4 +24,5 @@ def check(stmt):
:return:
"""

return sqlint.check(stmt)
return api.check(stmt)
'''
6 changes: 6 additions & 0 deletions src/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import sys

from .cli import main

if __name__ == '__main__':
sys.exit(main())
Empty file added src/checker/__init__.py
Empty file.
Loading