Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vasilevvitalii/mssqlrefine
Сlearing mssql text from comments and string variables
https://github.com/vasilevvitalii/mssqlrefine
Last synced: about 2 months ago
JSON representation
Сlearing mssql text from comments and string variables
- Host: GitHub
- URL: https://github.com/vasilevvitalii/mssqlrefine
- Owner: VasilevVitalii
- License: mit
- Created: 2023-02-05T09:13:33.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-05-03T17:56:39.000Z (over 1 year ago)
- Last Synced: 2024-10-23T11:23:48.225Z (2 months ago)
- Language: TypeScript
- Size: 158 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# mssqlrefine
Building tokens based on the mssql query text
## License
*MIT*
## Install
```
npm i mssqlrefine
```
## Example
```javascript
import { CreateRefineService } from 'mssqlrefine'const refineService = CreateRefineService()
refineService.prepareWorldsAll('upper')//build tokens in one iteration
const tokens1 = refineService.getTokens([
`select a, /*comment*/, [b]+[c], 'string' as d`,
`from mytable order by a --comment`
])//build tokens in two iterations
const tokens2 = refineService.getTokens([
`select a, /*comment*/, [b]+[c], 'string' as d`
])
tokens2.push(...refineService.getTokens([`from mytable order by a --comment`], tokens2))//tokens1 and tokens2 are equal
console.log(tokens1)
console.log(tokens2)
```
```json
[
{
"chunks": [
{
"idx": 0,
"kind": "code",
"kindCode": [
"statement",
"query",
"reserved"
],
"text": "SELECT"
},
{
"idx": 6,
"kind": "boundary",
"text": " "
},
{
"idx": 7,
"kind": "code",
"text": "a"
},
{
"idx": 8,
"kind": "comma",
"text": ","
},
{
"idx": 9,
"kind": "boundary",
"text": " "
},
{
"idx": 10,
"deepImpartible": 0,
"kind": "comment-multi",
"text": "/*comment*/"
},
{
"idx": 21,
"kind": "comma",
"text": ","
},
{
"idx": 22,
"kind": "boundary",
"text": " "
},
{
"idx": 23,
"deepImpartible": 0,
"kind": "code-in-bracket",
"text": "[b]"
},
{
"idx": 26,
"kind": "operator",
"text": "+"
},
{
"idx": 27,
"deepImpartible": 0,
"kind": "code-in-bracket",
"text": "[c]"
},
{
"idx": 30,
"kind": "comma",
"text": ","
},
{
"idx": 31,
"kind": "boundary",
"text": " "
},
{
"idx": 32,
"deepImpartible": 0,
"kind": "string",
"text": "'string'"
},
{
"idx": 40,
"kind": "boundary",
"text": " "
},
{
"idx": 41,
"kind": "code",
"kindCode": [
"statement",
"reserved"
],
"text": "AS"
},
{
"idx": 43,
"kind": "boundary",
"text": " "
},
{
"idx": 44,
"kind": "code",
"text": "d"
}
]
},
{
"chunks": [
{
"idx": 0,
"kind": "code",
"kindCode": [
"query",
"reserved"
],
"text": "FROM"
},
{
"idx": 4,
"kind": "boundary",
"text": " "
},
{
"idx": 5,
"kind": "code",
"text": "mytable"
},
{
"idx": 12,
"kind": "boundary",
"text": " "
},
{
"idx": 13,
"kind": "code",
"kindCode": [
"query",
"reserved"
],
"text": "ORDER"
},
{
"idx": 18,
"kind": "boundary",
"text": " "
},
{
"idx": 19,
"kind": "code",
"kindCode": [
"query",
"reserved"
],
"text": "BY"
},
{
"idx": 21,
"kind": "boundary",
"text": " "
},
{
"idx": 22,
"kind": "code",
"text": "a"
},
{
"idx": 23,
"kind": "boundary",
"text": " "
},
{
"idx": 24,
"kind": "comment-single",
"text": "--comment"
}
]
}
]
```