Skip to content

Commit

Permalink
Added "bigserial" and "smallserial" to the type mappings
Browse files Browse the repository at this point in the history
gfoidl authored and oskardudycz committed Nov 21, 2023
1 parent b836e42 commit 7c34bd9
Showing 3 changed files with 27 additions and 6 deletions.
10 changes: 9 additions & 1 deletion src/Weasel.Postgresql.Tests/PostgresqlProviderTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Data;
using System.Data;
using Npgsql;
using NpgsqlTypes;
using Shouldly;
@@ -94,6 +94,12 @@ public void table_columns_should_match_raw_types()
var serialAsInt = new TableColumn("id", "serial");
serialAsInt.ShouldBe(new TableColumn("id", "int"));

var bigserialAsBigint = new TableColumn("id", "bigserial");
bigserialAsBigint.ShouldBe(new TableColumn("id", "bigint"));

var smallserialAsSmallint = new TableColumn("id", "smallserial");
smallserialAsSmallint.ShouldBe(new TableColumn("id", "smallint"));

var varchararrAsArray = new TableColumn("comments", "varchar[]");
varchararrAsArray.ShouldBe(new TableColumn("comments", "array"));

@@ -111,6 +117,8 @@ public void table_columns_should_match_raw_types()
[InlineData("bool", "boolean")]
[InlineData("integer", "int")]
[InlineData("serial", "int")]
[InlineData("bigserial", "bigint")]
[InlineData("smallserial", "smallint")]
[InlineData("integer[]", "int[]")]
[InlineData("decimal", "decimal")]
[InlineData("numeric", "decimal")]
6 changes: 6 additions & 0 deletions src/Weasel.Postgresql/PostgresqlProvider.cs
Original file line number Diff line number Diff line change
@@ -109,6 +109,12 @@ public string ConvertSynonyms(string type)
case "serial":
return "int";

case "bigserial":
return "bigint";

case "smallserial":
return "smallint";

case "integer[]":
return "int[]";

17 changes: 12 additions & 5 deletions src/Weasel.Postgresql/Tables/TableColumn.cs
Original file line number Diff line number Diff line change
@@ -181,12 +181,19 @@ public string FullDeclaration()
}
}

public class SerialValue: ColumnCheck
public class SerialValue : ColumnCheck
{
public override string Declaration()
{
return "SERIAL";
}
public override string Declaration() => "SERIAL";
}

public class BigSerialValue : ColumnCheck
{
public override string Declaration() => "BIGSERIAL";
}

public class SmallSerialValue: ColumnCheck
{
public override string Declaration() => "SMALLSERIAL";
}

/*

0 comments on commit 7c34bd9

Please sign in to comment.