-
Notifications
You must be signed in to change notification settings - Fork 389
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
Add do-nothing SQL kernel to the builtin kernels in order to enable SQL language coloring #1105
Conversation
@@ -36,7 +36,7 @@ public class MsSqlKernel : | |||
public MsSqlKernel( | |||
string name, | |||
string connectionString, | |||
MsSqlServiceClient client) : base(name) | |||
MsSqlServiceClient client) : base(name, "SQL") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be "T-SQL"
or "MSSQL"
or something more specific.
@@ -45,6 +45,29 @@ public static Kernel FindKernel(this Kernel kernel, string name) | |||
}; | |||
} | |||
|
|||
public static Kernel FindKernel(this Kernel kernel, Func<Kernel, bool> selector) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should return IEnumerable<Kernel>
since there can be more than one that matches.
It would be more straightforward to use VisitSubkernels
and avoid looking at the ChooseKernelDirective
s.
|
||
Once installed, you can find more info about creating a SQL kernel and running queries by running the following help command: | ||
#!connect mssql -h | ||
"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the message is emitted as "text/markdown"
we can include a link to the package on NuGet.org, and people can find additional information that way.
A SQL kernel is not currently defined. | ||
|
||
SQL kernels are provided as part of the Microsoft.DotNet.Interactive.SqlServer package, which can be installed by using the following nuget command: | ||
#r Microsoft.DotNet.Interactive.SqlServer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closing this PR since @colombod is working on a different solution for this. |
This change adds a do-nothing SQL kernel that can be used to enable language coloring for SQL code. This is required because we can only define language grammars for fixed kernel names, but MSSQL kernel names are user-defined via the connect magic command, and thus aren't known ahead of time. The default SQL kernel displays a help message on execute if no actual SQL kernel exists, and does nothing otherwise. I also added a Language field to the base Kernel class so that we can better determine a kernel's capabilities without relying on its name.
Additionally, I incorporated the language grammar changes from @brettfo's PR here, for sake of completeness: #1099