CREATE TABLE: SPARSE MASKED WITH (...) column order (per MS docs) fails to parse; reversed order parses fine
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 75/100
Piste de recherche
Commencez par la grammaire de column_definition et reproduisez le problème avec TSql160Parser et l’instruction CREATE TABLE minimale. Comparez l’ordre documenté SPARSE MASKED avec l’ordre inversé qui fonctionne déjà dans les versions de l’analyseur concernées. Le travail est considéré comme terminé lorsque l’ordre documenté est analysé avec zéro erreur et que le comportement existant reste couvert.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Summary
CREATE TABLE column definitions that combine SPARSE and MASKED WITH (FUNCTION = ...) fail to parse (Incorrect syntax near 'MASKED') when the clauses appear in the order documented by Microsoft's own T-SQL reference (COLLATE → SPARSE → MASKED WITH). The reversed, non-standard order (MASKED WITH (...) before SPARSE) parses without error. This looks like an order-handling gap in the column_definition grammar rather than a missing feature — both SPARSE and MASKED WITH are individually well supported.
Repro
CREATE TABLE t (
c varchar(100) COLLATE SQL_Latin1_General_CP1_CI_AS SPARSE MASKED WITH (FUNCTION = 'default()') NULL
);
Minimal reduction (no COLLATE needed):
CREATE TABLE t (c varchar(100) SPARSE MASKED WITH (FUNCTION = 'default()') NULL);
TSql160Parser parser = new(initialQuotedIdentifiers: true);
using StringReader reader = new(sql);
TSqlFragment fragment = parser.Parse(reader, out IList<ParseError> errors);
// errors.Count == 1
// errors[0].Message == "Incorrect syntax near 'MASKED'."
Swapping the clause order makes the identical statement parse cleanly:
CREATE TABLE t (c varchar(100) MASKED WITH (FUNCTION = 'default()') SPARSE NULL);
-- errors.Count == 0
Per the official CREATE TABLE grammar reference (https://learn.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql), the documented <column_definition> order is:
column_name <data_type>
[ FILESTREAM ]
[ COLLATE collation_name ]
[ SPARSE ]
[ MASKED WITH ( FUNCTION = 'mask_function' ) ]
...
i.e. SPARSE before MASKED WITH. That documented order is exactly the order that fails to parse.
Scope tested
Parser classes (package version 180.37.3) — tested all concrete TSqlParser subclasses against the repro:
| Parser | Result |
|---|---|
TSql80Parser / TSql90Parser |
fails on SPARSE itself (expected — predates the feature) |
TSql100Parser / TSql110Parser / TSql120Parser |
Expected FILESTREAM but encountered MASKED instead. |
TSql130Parser … TSql180Parser |
Incorrect syntax near 'MASKED'. |
TSqlFabricDWParser |
Incorrect syntax near 'MASKED'. |
Every parser class from TSql100Parser onward (i.e. every version where MASKED is otherwise supported) rejects the SPARSE MASKED WITH (...) ordering.
Package versions — reproduced with the default (TSql160Parser)/latest-appropriate parser across every published version from 170.3.0 through the current latest:
170.3.0, 170.12.0, 170.64.0, 170.121.2, 170.157.0, 170.191.0, 180.6.0, 180.18.1, 180.37.3
All affected, no regression/fix in any tested version.
Expected behavior
COLLATE ... SPARSE MASKED WITH (FUNCTION = ...) — the order documented in Microsoft's own T-SQL reference, and valid, functioning DDL against a real SQL Server / Azure SQL instance — should parse without error, matching the already-working reversed order.
Additional notes
- Searched existing issues for
MASKED,SPARSE, and combinations thereof; found no duplicate. - Encountered this while building a T-SQL static-analysis tool against a real-world database schema using Dynamic Data Masking on sparse columns (a documented, supported SQL Server feature combination).
- Langage dominant
- GAP
- Étoiles
- 277
- Forks
- 43
- Merge moyen
- 9 j 23 h
- PR mergées (30 j)
- 2
Préparer son environnement
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de microsoft/SqlScriptDOM
-
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
microsoft/SqlScriptDOM#228 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
microsoft/SqlScriptDOM#183 ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 56/100
microsoft/SqlScriptDOM#226 · 1 réaction ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 48/100
microsoft/SqlScriptDOM#225 ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 58/100
microsoft/SqlScriptDOM#224 ·
Toutes les issues de microsoft/SqlScriptDOM
Issues similaires
-
bug engine spec compliance
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
frostney/GocciaScript#1402 ·
Les mainteneurs répondent en général sous 1 jour
-
bug needs triage
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour
-
After `require "openssl"`, a top-level `Digest` is `OpenSSL::Digest`, not the `Digest` moduleOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
yhirose/cpp-peglib#344 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour