mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 01:25:40 -05:00
Fix support for SQL DW in Edit Data scenarios (#379)
- SQL DW does not support SESSIONPROPERTY. Verified that the correct return values are "true" for both values on all DW instances
This commit is contained in:
@@ -512,25 +512,34 @@ SET NUMERIC_ROUNDABORT OFF;";
|
||||
Tuple<string,bool>[] sessionSettings = new Tuple<string,bool>[2];
|
||||
|
||||
IDbConnection connection = originalCommand.Connection;
|
||||
using (IDbCommand localCommand = connection.CreateCommand())
|
||||
if (IsSqlDwConnection(connection))
|
||||
{
|
||||
// Executing a reader requires preservation of any pending transaction created by the calling command
|
||||
localCommand.Transaction = originalCommand.Transaction;
|
||||
localCommand.CommandText = "SELECT ISNULL(SESSIONPROPERTY ('ANSI_NULLS'), 0), ISNULL(SESSIONPROPERTY ('QUOTED_IDENTIFIER'), 1)";
|
||||
using (IDataReader reader = localCommand.ExecuteReader())
|
||||
// SESSIONPROPERTY is not supported. Use default values for now
|
||||
sessionSettings[0] = Tuple.Create("ANSI_NULLS", true);
|
||||
sessionSettings[1] = Tuple.Create("QUOTED_IDENTIFIER", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
using (IDbCommand localCommand = connection.CreateCommand())
|
||||
{
|
||||
if (reader.Read())
|
||||
// Executing a reader requires preservation of any pending transaction created by the calling command
|
||||
localCommand.Transaction = originalCommand.Transaction;
|
||||
localCommand.CommandText = "SELECT ISNULL(SESSIONPROPERTY ('ANSI_NULLS'), 0), ISNULL(SESSIONPROPERTY ('QUOTED_IDENTIFIER'), 1)";
|
||||
using (IDataReader reader = localCommand.ExecuteReader())
|
||||
{
|
||||
sessionSettings[0] = Tuple.Create("ANSI_NULLS", ((int)reader[0] == 1));
|
||||
sessionSettings[1] = Tuple.Create("QUOTED_IDENTIFIER", ((int)reader[1] ==1));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Assert(false, "Reader cannot be empty");
|
||||
if (reader.Read())
|
||||
{
|
||||
sessionSettings[0] = Tuple.Create("ANSI_NULLS", ((int)reader[0] == 1));
|
||||
sessionSettings[1] = Tuple.Create("QUOTED_IDENTIFIER", ((int)reader[1] ==1));
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Assert(false, "Reader cannot be empty");
|
||||
}
|
||||
}
|
||||
}
|
||||
return sessionSettings;
|
||||
}
|
||||
return sessionSettings;
|
||||
}
|
||||
|
||||
private void SetSessionSettings(IDbConnection connection, params Tuple<string, bool>[] settings)
|
||||
|
||||
Reference in New Issue
Block a user