Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit 58a0e95

Browse files
committed
Add fixes for MySql + PostgreSQL
1 parent 935226c commit 58a0e95

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

src/ServiceStack.OrmLite.MySql/MySqlDialectProvider.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ public override string ToCreateTableStatement(Type tableType)
159159
var modelDef = GetModel(tableType);
160160
foreach (var fieldDef in modelDef.FieldDefinitions)
161161
{
162+
if (fieldDef.CustomSelect != null)
163+
continue;
164+
162165
if (sbColumns.Length != 0) sbColumns.Append(", \n ");
163166

164167
sbColumns.Append(GetColumnDefinition(fieldDef));

src/ServiceStack.OrmLite/OrmLiteUtils.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ internal static List<Tuple<FieldDefinition, int, IOrmLiteConverter>[]> GetMultiI
229229
var endPos = startPos;
230230
for (; endPos < reader.FieldCount; endPos++)
231231
{
232-
if (reader.GetName(endPos) == "EOT")
232+
if (string.Equals("EOT", reader.GetName(endPos), StringComparison.OrdinalIgnoreCase))
233233
break;
234234
}
235235

tests/ServiceStack.OrmLite.Tests/AutoQueryTests.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,14 @@ public void Can_Select_custom_fields_using_dynamic()
331331
var sb = new StringBuilder();
332332
foreach (var result in results)
333333
{
334-
sb.AppendLine(result.FirstName + "," + result.LastName + "," + result.Name);
334+
if (Dialect != Dialect.PostgreSql)
335+
{
336+
sb.AppendLine(result.FirstName + "," + result.LastName + "," + result.Name);
337+
}
338+
else
339+
{
340+
sb.AppendLine(result.first_name + "," + result.last_name + "," + result.name);
341+
}
335342
}
336343

337344
Assert.That(sb.ToString().NormalizeNewLines(), Is.EqualTo(
@@ -346,7 +353,14 @@ public void Can_Select_custom_fields_using_dynamic()
346353
sb.Length = 0;
347354
foreach (var result in results)
348355
{
349-
sb.AppendLine(result.Name);
356+
if (Dialect != Dialect.PostgreSql)
357+
{
358+
sb.AppendLine(result.Name);
359+
}
360+
else
361+
{
362+
sb.AppendLine(result.name);
363+
}
350364
}
351365

352366
Assert.That(sb.ToString().NormalizeNewLines(), Is.EqualTo("Dept 1\nDept 2\nDept 3\n"));

tests/ServiceStack.OrmLite.Tests/LoadReferencesJoinTests.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,8 @@ public void Can_load_references_with_OrderBy_and_Paging()
744744
[Test]
745745
public void Can_populate_multiple_POCOs_using_Dappers_QueryMultiple()
746746
{
747+
if (Dialect == Dialect.PostgreSql) return; //Dapper doesn't know about pgsql naming conventions
748+
747749
ResetTables();
748750
AddCustomerWithOrders();
749751

tests/ServiceStack.OrmLite.Tests/OrmLiteInsertTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ public void Can_InsertOnly_selected_fields_using_AssignmentExpression()
263263
db.DropAndCreateTable<PersonWithAutoId>();
264264

265265
db.InsertOnly(() => new PersonWithAutoId { FirstName = "Amy", Age = 27 });
266-
Assert.That(db.GetLastSql(), Is.EqualTo("INSERT INTO \"PersonWithAutoId\" (\"FirstName\",\"Age\") VALUES (@FirstName,@Age)"));
266+
Assert.That(db.GetLastSql().NormalizeSql(), Is.EqualTo("insert into personwithautoid (firstname,age) values (@firstname,@age)"));
267267

268268
var row = db.Select<PersonWithAutoId>()[0];
269269
Assert.That(row.FirstName, Is.EqualTo("Amy"));

0 commit comments

Comments
 (0)