Skip to content

Commit

Permalink
use feature detection for sequences
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Miller committed Aug 9, 2018
1 parent 7d5488a commit b8d8147
Showing 1 changed file with 19 additions and 2 deletions.
Expand Up @@ -131,8 +131,7 @@ public virtual DatabaseModel Create(DbConnection connection, IEnumerable<string>
var tableList = tables.ToList();
var tableFilter = GenerateTableFilter(tableList.Select(Parse).ToList(), schemaFilter);

if (Version.TryParse(connection.ServerVersion, out var serverVersion)
&& serverVersion.Major >= 11)
if (AreSequencesSupported(connection))
{
foreach (var sequence in GetSequences(connection, schemaFilter, typeAliases))
{
Expand Down Expand Up @@ -178,6 +177,24 @@ public virtual DatabaseModel Create(DbConnection connection, IEnumerable<string>
}
}

private bool AreSequencesSupported(DbConnection connection)
{
var command = connection.CreateCommand();
command.CommandType = CommandType.Text;
command.CommandText = "SELECT TOP 1 * FROM sys.sequences";

try
{
command.ExecuteReader();
}
catch
{
return false;
}

return true;
}

private string GetDefaultSchema(DbConnection connection)
{
using (var command = connection.CreateCommand())
Expand Down

0 comments on commit b8d8147

Please sign in to comment.