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

fix(@cspell/dict-sql): Add some more terms and ignore N' #1291

Merged
merged 1 commit into from
Jul 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 11 additions & 0 deletions dictionaries/sql/cspell-ext.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,24 @@
"description": "SQL dictionary for CSpell."
}
],
"patterns": [
{
"name": "sql-hex-number",
"pattern": "/0x[a-f0-9]*/gi"
},
{
"name": "sql-unicode-string-prefix",
"pattern": "/\\bN'/g"
}
],
"dictionaries": [],
"languageSettings": [
{
"languageId": "sql",
"locale": "*",
"patterns": [],
"dictionaries": ["sql"],
"ignoreRegExpList": ["sql-hex-number", "sql-unicode-string-prefix"],
"dictionaryDefinitions": []
}
]
Expand Down
16 changes: 9 additions & 7 deletions dictionaries/sql/cspell.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"version": "0.2",
"files": [
"**/*.{md,txt,sql}"
"files": ["**/*.{md,txt,sql}"],
"dictionaries": [],
"overrides": [
{
"filename": "*.txt",
"dictionaries": ["sql"]
}
],
"dictionaries": [
],
"import": [
"./cspell-ext.json"
]
"enableFiletypes": ["sql"],
"import": ["./cspell-ext.json"]
}
2 changes: 1 addition & 1 deletion dictionaries/sql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"./cspell-ext.json": "./cspell-ext.json"
},
"scripts": {
"build": "cross-env NODE_OPTIONS=--max_old_space_size=8192 cspell-tools-cli compile \"src/sql.txt\" -o .",
"build": "cat source-files.txt | xargs cspell-tools-cli compile -M sql -o .",
"test": "yarn test-dict && yarn test-samples",
"test-dict": "head -n 1000 \"src/sql.txt\" | cspell -v -c ./cspell-ext.json \"--local=*\" \"--languageId=sql\" stdin",
"test-samples": "cspell \"samples/**\"",
Expand Down
18 changes: 18 additions & 0 deletions dictionaries/sql/samples/notes.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- This is a collection of SQL Constants and terms

-- Character string constants
SELECT 'Cincinnati'
SELECT 'O''Brien'
SELECT 'Process X is 50% complete.'
SELECT 'The level for job_id: %d should be between %d and %d.'
SELECT "O'Brien"
SELECT N'time is running'

-- Binary constants
SELECT 0xAE
SELECT 0x12Ef
SELECT 0x69048AEFDD010E
SELECT 0xBADC0FFEED
SELECT 0x -- (empty binary string)

-- cspell:ignore Brien
26 changes: 26 additions & 0 deletions dictionaries/sql/samples/sample.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/************************************************************************************************************************************
* Generates the code to update the collation for all affected columns in the table *
************************************************************************************************************************************/
INSERT INTO #tempscriptstore (ScriptType,
script)
SELECT 'AlterCollation',
N'ALTER TABLE ' + QUOTENAME(@SchemaName) + N'.' + QUOTENAME(@TableName) + N' ALTER COLUMN '
+ QUOTENAME(c.name) + ' '
+ CASE WHEN ty.name = N'ntext'
THEN ty.name + N' COLLATE ' + @DatabaseCollation + ' '
ELSE ty.name + N'(' + CASE WHEN c.max_length = -1
THEN N'MAX'
ELSE CASE WHEN ty.name = N'nvarchar'
THEN CAST(c.max_length / 2 AS nvarchar(20))
ELSE CAST(c.max_length AS nvarchar(20))
END
END + N') COLLATE ' + @DatabaseCollation
END + CASE WHEN c.is_nullable = 1 THEN N' NULL;' ELSE N' NOT NULL;' END
FROM sys.columns AS c
INNER JOIN sys.types AS ty
ON ty.system_type_id = c.system_type_id
AND ty.name <> N'sysname'
WHERE c.object_id = @object_id
AND c.collation_name <> @DatabaseCollation;

-- cspell:ignore tempscriptstore
2 changes: 2 additions & 0 deletions dictionaries/sql/source-files.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src/sql.txt
src/tsql.txt
Loading