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

Commit 796b0df

Browse files
committed
Merge pull request #365 from jeffgabhart/pg-with-query
PostgreSQL - Select<T> does not handle WITH query.
2 parents 8f78c56 + e191d78 commit 796b0df

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

lib/Mono.Security.dll

9 KB
Binary file not shown.

lib/Npgsql.dll

-40 KB
Binary file not shown.

src/ServiceStack.OrmLite.PostgreSQL.Tests/OrmLiteSelectTests.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,5 +324,28 @@ public void Can_Select_In_for_string_value()
324324
}
325325
}
326326

327+
[Test]
328+
public void Can_Select_With_Subquery()
329+
{
330+
const int n = 5;
331+
332+
using (var db = OpenDbConnection())
333+
{
334+
db.CreateTable<ModelWithFieldsOfDifferentTypes>();
335+
336+
n.Times(x => db.Insert(ModelWithFieldsOfDifferentTypes.Create(n)));
337+
338+
var sql = @"
339+
WITH max_id AS (
340+
SELECT 3 AS three)
341+
SELECT *
342+
FROM ModelWithFieldsOfDifferentTypes
343+
WHERE id <= (SELECT three FROM max_id)";
344+
345+
var rows = db.Select<ModelWithFieldsOfDifferentTypes>(sql);
346+
347+
Assert.That(rows.Count, Is.EqualTo((3)));
348+
}
349+
}
327350
}
328351
}

0 commit comments

Comments
 (0)