Skip to content
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

Floor the sequence values to long Min and Max #22938

Merged
merged 1 commit into from
Oct 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -392,9 +392,21 @@ private void GetSequences(
CAST([s].[scale] AS int) AS [scale],
[s].[is_cycling],
CAST([s].[increment] AS int) AS [increment],
CAST([s].[start_value] AS bigint) AS [start_value],
CAST([s].[minimum_value] AS bigint) AS [minimum_value],
CAST([s].[maximum_value] AS bigint) AS [maximum_value]
CAST(CASE
WHEN [s].[start_value] > 9223372036854775807 THEN 9223372036854775807
WHEN [s].[start_value] < -9223372036854775808 THEN -9223372036854775808
ELSE [s].[start_value]
END AS bigint) AS start_value,
CAST(CASE
WHEN [s].[minimum_value] > 9223372036854775807 THEN 9223372036854775807
WHEN [s].[minimum_value] < -9223372036854775808 THEN -9223372036854775808
ELSE [s].[minimum_value]
END AS bigint) AS minimum_value,
CAST(CASE
WHEN [s].[maximum_value] > 9223372036854775807 THEN 9223372036854775807
WHEN [s].[maximum_value] < -9223372036854775808 THEN -9223372036854775808
ELSE [s].[maximum_value]
END AS bigint) AS maximum_value
FROM [sys].[sequences] AS [s]
JOIN [sys].[types] AS [t] ON [s].[user_type_id] = [t].[user_type_id]";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,38 @@ public void Sequence_min_max_start_values_are_not_null_if_decimal()
DROP SEQUENCE [NumericSequence];");
}

[ConditionalFact]
public void Sequence_high_min_max_start_values_are_not_null_if_decimal()
{
Test(
@"
CREATE SEQUENCE [dbo].[HighDecimalSequence]
AS [numeric](38, 0)
START WITH -99999999999999999999999999999999999999
INCREMENT BY 1
MINVALUE -99999999999999999999999999999999999999
MAXVALUE 99999999999999999999999999999999999999
CACHE;",
Enumerable.Empty<string>(),
Enumerable.Empty<string>(),
dbModel =>
{
Assert.All(
dbModel.Sequences,
s =>
{
Assert.NotNull(s.StartValue);
Assert.Equal(long.MinValue, s.StartValue);
Assert.NotNull(s.MinValue);
Assert.Equal(long.MinValue, s.MinValue);
Assert.NotNull(s.MaxValue);
Assert.Equal(long.MaxValue, s.MaxValue);
});
},
@"
DROP SEQUENCE [HighDecimalSequence];");
}

[ConditionalFact]
public void Sequence_using_type_alias()
{
Expand Down