Skip to content

Commit adb0023

Browse files
JaBistDuNarrischJaBistDuNarrisch
authored andcommitted
Added Postgre type bytea for DbType.Binary
1 parent 355ff7e commit adb0023

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/Migrator.Tests/Providers/PostgreSQL/PostgreSQLTransformationProvider_GetColumnsTypeTests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public void GetColumns_DataTypeResolveSucceeds()
2323
const string int64ColumnName1 = "int64column1";
2424
const string stringColumnName1 = "stringcolumn1";
2525
const string stringColumnName2 = "stringcolumn2";
26+
const string byteColumnName = "bytecolumn";
2627

2728
// Should be extended by remaining types
2829
Provider.AddTable(testTableName,

src/Migrator/Providers/Impl/PostgreSQL/PostgreSQLTransformationProvider.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,9 +368,13 @@ public override Column[] GetColumns(string table)
368368
dbType = DbType.String;
369369
size = characterMaximumLength;
370370
}
371+
else if (dataTypeString == "bytea")
372+
{
373+
dbType = DbType.Binary;
374+
}
371375
else if (dataTypeString == "character" || dataTypeString.StartsWith("character("))
372376
{
373-
throw new NotSupportedException("Data type 'character' detected. We do not support 'character'. Use 'text' or 'character varying' instead");
377+
throw new NotSupportedException("Data type 'character' detected. 'character' is not supported. Use 'text' or 'character varying' instead.");
374378
}
375379
else
376380
{
@@ -427,7 +431,7 @@ public override Column[] GetColumns(string table)
427431

428432
if (!match.Success)
429433
{
430-
throw new Exception("Postgre default value for date time: We expect single quotes around the date time string.");
434+
throw new Exception("Postgre default value for date time: Single quotes around the date time string are expected.");
431435
}
432436

433437
var timeString = match.Value;
@@ -450,7 +454,7 @@ public override Column[] GetColumns(string table)
450454

451455
if (!match.Success)
452456
{
453-
throw new Exception("Postgre default value for uniqueidentifier: We expected single quotes around the Guid string.");
457+
throw new Exception("Postgre default value for uniqueidentifier: Single quotes around the Guid string are expected.");
454458
}
455459

456460
column.DefaultValue = Guid.Parse(match.Value);
@@ -472,7 +476,7 @@ public override Column[] GetColumns(string table)
472476

473477
if (!match.Success)
474478
{
475-
throw new Exception("Postgre default value for date time: We expected single quotes around the date time string.");
479+
throw new Exception("Postgre default value for date time: Single quotes around the date time string are expected.");
476480
}
477481

478482
column.DefaultValue = match.Value;

0 commit comments

Comments
 (0)