Skip to content

Commit 70405d0

Browse files
rojimikeharder
authored andcommitted
Lowercase table names (#130)
This makes raw queries compatible with PostgreSQL. Also modified raw SQL commands to use lowercase column and table names.
1 parent a574eed commit 70405d0

File tree

5 files changed

+7
-5
lines changed

5 files changed

+7
-5
lines changed

src/Benchmarks/Data/BatchUpdateString.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ internal class BatchUpdateString
1414
{
1515
Id = $"Id_{i}",
1616
Random = $"Random_{i}",
17-
UpdateQuery = $"UPDATE world SET randomNumber = @Random_{i} WHERE id = @Id_{i};"
17+
UpdateQuery = $"UPDATE world SET randomnumber = @Random_{i} WHERE id = @Id_{i};"
1818
}).ToArray();
1919

2020
public string Id { get; set; }

src/Benchmarks/Data/DapperDb.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public async Task<World> LoadSingleQueryRow()
4040
async Task<World> ReadSingleRow(DbConnection db)
4141
{
4242
return await db.QueryFirstOrDefaultAsync<World>(
43-
"SELECT Id, RandomNumber FROM World WHERE Id = @Id",
43+
"SELECT id, randomnumber FROM world WHERE Id = @Id",
4444
new { Id = _random.Next(1, 10001) });
4545
}
4646

@@ -105,7 +105,7 @@ public async Task<IEnumerable<Fortune>> LoadFortunesRows()
105105
db.ConnectionString = _connectionString;
106106

107107
// Note: don't need to open connection if only doing one thing; let dapper do it
108-
result = (await db.QueryAsync<Fortune>("SELECT Id, Message FROM Fortune")).AsList();
108+
result = (await db.QueryAsync<Fortune>("SELECT id, message FROM fortune")).AsList();
109109
}
110110

111111
result.Add(new Fortune { Message = "Additional fortune added at request time." });

src/Benchmarks/Data/Fortune.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
namespace Benchmarks.Data
99
{
10+
[Table("fortune")]
1011
public class Fortune : IComparable<Fortune>, IComparable
1112
{
1213
[Column("id")]

src/Benchmarks/Data/RawDb.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async Task<World> ReadSingleRow(DbConnection connection, DbCommand cmd)
5454
DbCommand CreateReadCommand(DbConnection connection)
5555
{
5656
var cmd = connection.CreateCommand();
57-
cmd.CommandText = "SELECT Id, RandomNumber FROM World WHERE Id = @Id";
57+
cmd.CommandText = "SELECT id, randomnumber FROM world WHERE id = @Id";
5858
var id = cmd.CreateParameter();
5959
id.ParameterName = "@Id";
6060
id.DbType = DbType.Int32;
@@ -139,7 +139,7 @@ public async Task<IEnumerable<Fortune>> LoadFortunesRows()
139139
using (var db = _dbProviderFactory.CreateConnection())
140140
using (var cmd = db.CreateCommand())
141141
{
142-
cmd.CommandText = "SELECT Id, Message FROM Fortune";
142+
cmd.CommandText = "SELECT id, message FROM fortune";
143143

144144
db.ConnectionString = _connectionString;
145145
await db.OpenAsync();

src/Benchmarks/Data/World.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
namespace Benchmarks.Data
77
{
8+
[Table("world")]
89
public class World
910
{
1011
[Column("id")]

0 commit comments

Comments
 (0)