0

Queries are read fine when debugging only My Code. However, when disabling the option in Visual Studio in 'Debug > Options > Enable Just My Code', antlr.MismatchedTokenException is thrown for almost every SQL query which is run through the parser.

Here's a simplified example, which throws:

antlr.MismatchedTokenException 'expecting "Dot", found 'AS''

Ignoring the exceptions, the select statement works fine and is passed to the app no problem. But the constant spam of .NET exceptions is puzzling. The literal interpretation of the exception doesn't seem to make sense for this SQL query.

I can't see anything wrong with this example query.

private static StatementList PrepareSql(string sql)
        {
            sql = "SELECT A.[ID] AS [Activities_Id] FROM [Activities] A";

            var parser = new TSql140Parser(false, SqlEngineType.SqlAzure);

            return parser.ParseStatementList(new StringReader(sql), out var errors1);
        }

--

Update: We believe the exception occurs not in the immediate library referenced by the portal, but in ANTLR. We still cannot find the reason for the exception. Currently we've added a workaround to cache the SQL query so that the exception is only thrown once per query - but that's still one too many.

  • Maybe try simplifying the SQL statement to work out what is not parsing. I would assume that it does not like the square brackets (I know Azure Cosmos doesn't use square brackets, but I'm not sure if "SqlAzure" is the same as Azure Cosmos). Try removing the square brackets, and simplify the query to something like "SELECT ID FROM Activities" and build up from there to see what the issue is – Steve Norwood Feb 16 '22 at 08:29
  • Thanks @SteveNorwood - simplifying the query to "SELECT ID FROM ACTIVITIES" also throws an exception - expecting "Dot", found 'FROM''. Even "SELECT Activities.ID FROM Activities" returns the same. – chairmanbertie Feb 16 '22 at 08:31
  • What **exactly** does this sentence mean: "but when allowing exceptions from .NET code" ? – Lasse V. Karlsen Feb 16 '22 at 08:44
  • Sorry @LasseV.Karlsen I mean when in Visual Studio: Debug > Options > Enable Just My Code is DISABLED. – chairmanbertie Feb 16 '22 at 08:49
  • Are you stopping on every exception? Have you enabled this option? – Lasse V. Karlsen Feb 16 '22 at 08:52
  • Sorry I'm not entirely sure what you mean. Exception Settings have all enabled - so it is breaking on anything and everything. This is the first exception that is raised, no others are bypassed prior. – chairmanbertie Feb 16 '22 at 09:06

0 Answers0