mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -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];
|
Tuple<string,bool>[] sessionSettings = new Tuple<string,bool>[2];
|
||||||
|
|
||||||
IDbConnection connection = originalCommand.Connection;
|
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
|
// SESSIONPROPERTY is not supported. Use default values for now
|
||||||
localCommand.Transaction = originalCommand.Transaction;
|
sessionSettings[0] = Tuple.Create("ANSI_NULLS", true);
|
||||||
localCommand.CommandText = "SELECT ISNULL(SESSIONPROPERTY ('ANSI_NULLS'), 0), ISNULL(SESSIONPROPERTY ('QUOTED_IDENTIFIER'), 1)";
|
sessionSettings[1] = Tuple.Create("QUOTED_IDENTIFIER", true);
|
||||||
using (IDataReader reader = localCommand.ExecuteReader())
|
}
|
||||||
|
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));
|
if (reader.Read())
|
||||||
sessionSettings[1] = Tuple.Create("QUOTED_IDENTIFIER", ((int)reader[1] ==1));
|
{
|
||||||
}
|
sessionSettings[0] = Tuple.Create("ANSI_NULLS", ((int)reader[0] == 1));
|
||||||
else
|
sessionSettings[1] = Tuple.Create("QUOTED_IDENTIFIER", ((int)reader[1] ==1));
|
||||||
{
|
}
|
||||||
Debug.Assert(false, "Reader cannot be empty");
|
else
|
||||||
|
{
|
||||||
|
Debug.Assert(false, "Reader cannot be empty");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return sessionSettings;
|
|
||||||
}
|
}
|
||||||
|
return sessionSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetSessionSettings(IDbConnection connection, params Tuple<string, bool>[] settings)
|
private void SetSessionSettings(IDbConnection connection, params Tuple<string, bool>[] settings)
|
||||||
|
|||||||
Reference in New Issue
Block a user