Skip to content

Commit

Permalink
Merge pull request PostgreSQLCopyHelper#48 from PostgreSQLCopyHelper/…
Browse files Browse the repository at this point in the history
…2.5.0-alpha

2.5.0
  • Loading branch information
bytefish authored Sep 27, 2019
2 parents a355952 + 9ef49be commit eaad89a
Show file tree
Hide file tree
Showing 40 changed files with 277 additions and 140 deletions.
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"cSpell.words": [
"Inet",
"Npgsql",
"Postgres",
"bigint",
"bytea",
"macaddr",
"philipp",
"smallint",
"ulong"
]
}
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# CHANGELOG #

## 2.5.0 ##

* [See Changes](https://github.com/bytefish/PostgreSQLCopyHelper/compare/2.4.0...2.5.0)

#### This release:
- Drops support for `net45`, `net451` and `net452`
- Upgrades Npgsql to 4.1
- SaveAll now returns a count of rows written

## 2.4.2 ##

* [See Changes](https://github.com/bytefish/PostgreSQLCopyHelper/compare/2.3.0...2.4.2)
Expand Down Expand Up @@ -82,4 +91,4 @@ Adding .netstandard1.3 as Target Framework to support .NET Core.

* [See Changes](https://github.com/bytefish/PostgreSQLCopyHelper/compare/0.2...1.0.0)

Initial Release.
Initial Release.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) Philipp Wagner and Contributors
Copyright (c) Philipp Wagner, Steven Yeh and Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
22 changes: 22 additions & 0 deletions PostgreSQLCopyHelper/PostgreSQLCopyHelper/NuGet.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="npgsql-unstable myget" value="https://www.myget.org/F/npgsql-unstable/api/v3/index.json" protocolVersion="3" />
</packageSources>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
<bindingRedirects>
<add key="skip" value="False" />
</bindingRedirects>
<packageManagement>
<add key="format" value="1" />
<add key="disabled" value="False" />
</packageManagement>
<disabledPackageSources />
<config>
<add key="dependencyVersion" value="HighestPatch" />
</config>
</configuration>
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Copyright (c) Philipp Wagner. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -66,12 +65,13 @@ public void Test_StringArray()
Array = new[] { "A", "B" }
};

subject.SaveAll(connection, new[] { entity0 });
var recordsSaved = subject.SaveAll(connection, new[] { entity0 });

var result = GetAll();

// Check if we have the amount of rows:
Assert.AreEqual(1, result.Count);
Assert.AreEqual(1, recordsSaved);

// Check if the Result is not null:
Assert.IsNotNull(result[0][0]);
Expand Down Expand Up @@ -311,7 +311,7 @@ private int CreateTable(string arrayType)
return sqlCommand.ExecuteNonQuery();
}

private List<object[]> GetAll()
private IList<object[]> GetAll()
{
return connection.GetAll("sample", "unit_test");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Copyright (c) Philipp Wagner. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -69,9 +68,6 @@ protected override void OnSetupInTransaction()
.MapTimeTz("col_timetz_time_span", x => x.TimeSpan_TimeTz)
.MapTimeTz("col_timetz_date_time", x => x.DateTime_TimeTz)
.MapTimeTz("col_timetz_date_time_offset", x => x.DateTimeOffset_TimeTz);



}

private int CreateTable()
Expand Down Expand Up @@ -114,8 +110,7 @@ public void Test_TimeStampTz_DateTimeOffset()
{
DateTimeOffset_TimestampTz = new DateTimeOffset(2019, 1, 1, 22, 0, 0, TimeSpan.Zero)
};



subject.SaveAll(connection, new[] { entity0 });

var result = GetAll();
Expand Down Expand Up @@ -168,12 +163,13 @@ public void Test_NullableSmallInt()
SmallInt = Int16.MaxValue
};

subject.SaveAll(connection, new[] { entity0, entity1 });
var recordsSaved = subject.SaveAll(connection, new[] { entity0, entity1 });

var result = GetAll();

// Check if we have the amount of rows:
Assert.AreEqual(2, result.Count);
Assert.AreEqual(2, recordsSaved);

Assert.IsNotNull(result[0][0]);
Assert.IsNotNull(result[1][0]);
Expand All @@ -185,7 +181,6 @@ public void Test_NullableSmallInt()
[Test]
public void Test_NullableInteger()
{

var entity0 = new TestEntity()
{
Integer = Int32.MinValue
Expand All @@ -196,12 +191,13 @@ public void Test_NullableInteger()
Integer = Int32.MaxValue
};

subject.SaveAll(connection, new[] { entity0, entity1 });
var recordSaved = subject.SaveAll(connection, new[] { entity0, entity1 });

var result = GetAll();

// Check if we have the amount of rows:
Assert.AreEqual(2, result.Count);
Assert.AreEqual(2, recordSaved);

Assert.IsNotNull(result[0][1]);
Assert.IsNotNull(result[1][1]);
Expand All @@ -213,7 +209,6 @@ public void Test_NullableInteger()
[Test]
public void Test_NullableMoney()
{

var entity0 = new TestEntity()
{
Money = -1234567890123.45M
Expand All @@ -224,12 +219,13 @@ public void Test_NullableMoney()
Money = 92233720368547758.07M
};

subject.SaveAll(connection, new[] { entity0, entity1 });
var recordSaved = subject.SaveAll(connection, new[] { entity0, entity1 });

var result = GetAll();

// Check if we have the amount of rows:
Assert.AreEqual(2, result.Count);
Assert.AreEqual(2, recordSaved);

Assert.IsNotNull(result[0][2]);
Assert.IsNotNull(result[1][2]);
Expand All @@ -241,7 +237,6 @@ public void Test_NullableMoney()
[Test]
public void Test_NullableNumeric()
{

var entity0 = new TestEntity()
{
Numeric = Decimal.MinValue
Expand All @@ -252,12 +247,13 @@ public void Test_NullableNumeric()
Numeric = Decimal.MaxValue
};

subject.SaveAll(connection, new[] { entity0, entity1 });
var recordSaved = subject.SaveAll(connection, new[] { entity0, entity1 });

var result = GetAll();

// Check if we have the amount of rows:
Assert.AreEqual(2, result.Count);
Assert.AreEqual(2, recordSaved);

Assert.AreEqual(entity0.Numeric, (Decimal) result[0][9]);
Assert.AreEqual(entity1.Numeric, (Decimal) result[1][9]);
Expand All @@ -276,12 +272,13 @@ public void Test_NullableBigint()
BigInt = Int64.MaxValue
};

subject.SaveAll(connection, new[] { entity0, entity1 });
var recordSaved = subject.SaveAll(connection, new[] { entity0, entity1 });

var result = GetAll();

// Check if we have the amount of rows:
Assert.AreEqual(2, result.Count);
Assert.AreEqual(2, recordSaved);

Assert.IsNotNull(result[0][3]);
Assert.IsNotNull(result[1][3]);
Expand Down Expand Up @@ -348,12 +345,13 @@ public void Test_NullableReal()
Real = Single.MaxValue
};

subject.SaveAll(connection, new[] { entity0, entity1 });
var recordSaved = subject.SaveAll(connection, new[] { entity0, entity1 });

var result = GetAll();

// Check if we have the amount of rows:
Assert.AreEqual(2, result.Count);
Assert.AreEqual(2, recordSaved);

Assert.IsNotNull(result[0][5]);
Assert.IsNotNull(result[1][5]);
Expand All @@ -375,12 +373,13 @@ public void Test_NullableDouble()
DoublePrecision = Double.MaxValue
};

subject.SaveAll(connection, new[] { entity0, entity1 });
var recordSaved = subject.SaveAll(connection, new[] { entity0, entity1 });

var result = GetAll();

// Check if we have the amount of rows:
Assert.AreEqual(2, result.Count);
Assert.AreEqual(2, recordSaved);

Assert.AreEqual(entity0.DoublePrecision, (Double) result[0][6]);
Assert.AreEqual(entity1.DoublePrecision, (Double) result[1][6]);
Expand All @@ -394,12 +393,13 @@ public void Test_ByteArray()
ByteArray = new byte[] { 1, 2, 3 }
};

subject.SaveAll(connection, new[] { entity0 });
var recordSaved = subject.SaveAll(connection, new[] { entity0 });

var result = GetAll();

// Check if we have the amount of rows:
Assert.AreEqual(1, result.Count);
Assert.AreEqual(1, recordSaved);

Assert.AreEqual(entity0.ByteArray[0], ((byte[]) result[0][7])[0]);
Assert.AreEqual(entity0.ByteArray[1], ((byte[]) result[0][7])[1]);
Expand All @@ -419,12 +419,13 @@ public void Test_NullableUUID()
UUID = Guid.NewGuid()
};

subject.SaveAll(connection, new[] { entity0, entity1 });
var recordSaved = subject.SaveAll(connection, new[] { entity0, entity1 });

var result = GetAll();

// Check if we have the amount of rows:
Assert.AreEqual(2, result.Count);
Assert.AreEqual(2, recordSaved);

Assert.AreEqual(entity0.UUID, (Guid) result[0][8]);
Assert.AreEqual(entity1.UUID, (Guid) result[1][8]);
Expand All @@ -443,12 +444,13 @@ public void Test_NullableDate()
Date = DateTime.UtcNow
};

subject.SaveAll(connection, new[] { entity0, entity1 });
var recordSaved = subject.SaveAll(connection, new[] { entity0, entity1 });

var result = GetAll();

// Check if we have the amount of rows:
Assert.AreEqual(2, result.Count);
Assert.AreEqual(2, recordSaved);

Assert.IsNotNull(result[0][12]);
Assert.IsNotNull(result[1][12]);
Expand Down Expand Up @@ -479,12 +481,13 @@ public void Test_IpAddress()
IpAddress = IPAddress.Parse("1.2.3.4")
};

subject.SaveAll(connection, new[] { entity0, entity1 });
var recordSaved = subject.SaveAll(connection, new[] { entity0, entity1 });

var result = GetAll();

// Check if we have the amount of rows:
Assert.AreEqual(2, result.Count);
Assert.AreEqual(2, recordSaved);

Assert.IsNotNull(result[0][10]);
Assert.IsNotNull(result[1][10]);
Expand All @@ -510,12 +513,13 @@ public void Test_MacAddress()
MacAddress = PhysicalAddress.Parse("01-02-2B-01-02-03")
};

subject.SaveAll(connection, new[] { entity0, entity1 });
var recordsSaved = subject.SaveAll(connection, new[] { entity0, entity1 });

var result = GetAll();

// Check if we have the amount of rows:
Assert.AreEqual(2, result.Count);
Assert.AreEqual(2, recordsSaved);

Assert.IsNotNull(result[0][11]);
Assert.IsNotNull(result[1][11]);
Expand All @@ -542,12 +546,13 @@ public void Test_NullableTimeSpan()
};


subject.SaveAll(connection, new[] { entity0, entity1 });
var recordsSaved = subject.SaveAll(connection, new[] { entity0, entity1 });

var result = GetAll();

// Check if we have the amount of rows:
Assert.AreEqual(2, result.Count);
Assert.AreEqual(2, recordsSaved);

Assert.AreEqual(entity0.TimeSpan, (TimeSpan) result[0][13]);
Assert.AreEqual(entity1.TimeSpan, (TimeSpan) result[1][13]);
Expand All @@ -574,12 +579,13 @@ public void Test_Json()
};


subject.SaveAll(connection, new[] { entity0, entity1 });
var recordSaved = subject.SaveAll(connection, new[] { entity0, entity1 });

var result = GetAll();

// Check if we have the amount of rows:
Assert.AreEqual(2, result.Count);
Assert.AreEqual(2, recordSaved);

Assert.IsNotNull(result[0][14]);
Assert.IsNotNull(result[1][14]);
Expand Down Expand Up @@ -613,20 +619,21 @@ public void Test_Jsonb()
};


subject.SaveAll(connection, new[] { entity0, entity1 });
var recordSaved = subject.SaveAll(connection, new[] { entity0, entity1 });

var result = GetAll();

// Check if we have the amount of rows:
Assert.AreEqual(2, result.Count);
Assert.AreEqual(2, recordSaved);

Assert.IsNotNull(result[0][15]);
Assert.IsNotNull(result[1][15]);

// TODO: More Useful Test for JSON equality here...
}

private List<object[]> GetAll()
private IList<object[]> GetAll()
{
return connection.GetAll("sample", "unit_test");
}
Expand Down
Loading

0 comments on commit eaad89a

Please sign in to comment.