Skip to content

Commit 3f4d78c

Browse files
fix: add example of storing datetime value as Sqlite integer
1 parent 7712c7f commit 3f4d78c

14 files changed

Lines changed: 35 additions & 39 deletions

File tree

examples/SqliteDapperExample/QuerySql.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ public async Task InsertSqliteTypesBatch(List<InsertSqliteTypesBatchArgs> args)
575575
}
576576
}
577577

578-
private const string GetSqliteTypesSql = "SELECT c_integer, c_real, c_text, c_blob, created_at, updated_at FROM types_sqlite LIMIT 1";
578+
private const string GetSqliteTypesSql = "SELECT c_integer, c_real, c_text, c_blob, created_at, datetime(updated_at, 'unixepoch') AS updated_at FROM types_sqlite LIMIT 1";
579579
public class GetSqliteTypesRow
580580
{
581581
public int? CInteger { get; init; }

examples/SqliteDapperExample/request.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@
11151115
}
11161116
},
11171117
{
1118-
"text": "SELECT c_integer, c_real, c_text, c_blob, created_at, updated_at FROM types_sqlite LIMIT 1",
1118+
"text": "SELECT \n c_integer, c_real, c_text, c_blob, \n created_at, datetime(updated_at, 'unixepoch') AS updated_at\nFROM types_sqlite \nLIMIT 1",
11191119
"name": "GetSqliteTypes",
11201120
"cmd": ":one",
11211121
"columns": [
@@ -1177,13 +1177,10 @@
11771177
{
11781178
"name": "updated_at",
11791179
"length": -1,
1180-
"table": {
1181-
"name": "types_sqlite"
1182-
},
1180+
"isFuncCall": true,
11831181
"type": {
1184-
"name": "INTEGER"
1185-
},
1186-
"originalName": "updated_at"
1182+
"name": "any"
1183+
}
11871184
}
11881185
],
11891186
"filename": "query.sql"
19 Bytes
Binary file not shown.

examples/SqliteDapperLegacyExample/QuerySql.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ public async Task InsertSqliteTypesBatch(List<InsertSqliteTypesBatchArgs> args)
576576
}
577577
}
578578

579-
private const string GetSqliteTypesSql = "SELECT c_integer, c_real, c_text, c_blob, created_at, updated_at FROM types_sqlite LIMIT 1";
579+
private const string GetSqliteTypesSql = "SELECT c_integer, c_real, c_text, c_blob, created_at, datetime(updated_at, 'unixepoch') AS updated_at FROM types_sqlite LIMIT 1";
580580
public class GetSqliteTypesRow
581581
{
582582
public int? CInteger { get; set; }

examples/SqliteDapperLegacyExample/request.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@
11151115
}
11161116
},
11171117
{
1118-
"text": "SELECT c_integer, c_real, c_text, c_blob, created_at, updated_at FROM types_sqlite LIMIT 1",
1118+
"text": "SELECT \n c_integer, c_real, c_text, c_blob, \n created_at, datetime(updated_at, 'unixepoch') AS updated_at\nFROM types_sqlite \nLIMIT 1",
11191119
"name": "GetSqliteTypes",
11201120
"cmd": ":one",
11211121
"columns": [
@@ -1177,13 +1177,10 @@
11771177
{
11781178
"name": "updated_at",
11791179
"length": -1,
1180-
"table": {
1181-
"name": "types_sqlite"
1182-
},
1180+
"isFuncCall": true,
11831181
"type": {
1184-
"name": "INTEGER"
1185-
},
1186-
"originalName": "updated_at"
1182+
"name": "any"
1183+
}
11871184
}
11881185
],
11891186
"filename": "query.sql"
19 Bytes
Binary file not shown.

examples/SqliteExample/QuerySql.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ public async Task InsertSqliteTypesBatch(List<InsertSqliteTypesBatchArgs> args)
740740
}
741741
}
742742

743-
private const string GetSqliteTypesSql = "SELECT c_integer, c_real, c_text, c_blob, created_at, updated_at FROM types_sqlite LIMIT 1";
743+
private const string GetSqliteTypesSql = "SELECT c_integer, c_real, c_text, c_blob, created_at, datetime(updated_at, 'unixepoch') AS updated_at FROM types_sqlite LIMIT 1";
744744
public readonly record struct GetSqliteTypesRow(int? CInteger, decimal? CReal, string? CText, byte[]? CBlob, DateTime CreatedAt, DateTime? UpdatedAt);
745745
public async Task<GetSqliteTypesRow?> GetSqliteTypes()
746746
{

examples/SqliteExample/request.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@
11151115
}
11161116
},
11171117
{
1118-
"text": "SELECT c_integer, c_real, c_text, c_blob, created_at, updated_at FROM types_sqlite LIMIT 1",
1118+
"text": "SELECT \n c_integer, c_real, c_text, c_blob, \n created_at, datetime(updated_at, 'unixepoch') AS updated_at\nFROM types_sqlite \nLIMIT 1",
11191119
"name": "GetSqliteTypes",
11201120
"cmd": ":one",
11211121
"columns": [
@@ -1177,13 +1177,10 @@
11771177
{
11781178
"name": "updated_at",
11791179
"length": -1,
1180-
"table": {
1181-
"name": "types_sqlite"
1182-
},
1180+
"isFuncCall": true,
11831181
"type": {
1184-
"name": "INTEGER"
1185-
},
1186-
"originalName": "updated_at"
1182+
"name": "any"
1183+
}
11871184
}
11881185
],
11891186
"filename": "query.sql"
19 Bytes
Binary file not shown.

examples/SqliteLegacyExample/QuerySql.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -853,7 +853,7 @@ public async Task InsertSqliteTypesBatch(List<InsertSqliteTypesBatchArgs> args)
853853
}
854854
}
855855

856-
private const string GetSqliteTypesSql = "SELECT c_integer, c_real, c_text, c_blob, created_at, updated_at FROM types_sqlite LIMIT 1";
856+
private const string GetSqliteTypesSql = "SELECT c_integer, c_real, c_text, c_blob, created_at, datetime(updated_at, 'unixepoch') AS updated_at FROM types_sqlite LIMIT 1";
857857
public class GetSqliteTypesRow
858858
{
859859
public int? CInteger { get; set; }

0 commit comments

Comments
 (0)